From e61c6cd3dbc756b363f6e5441d67e207605c1dc0 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Tue, 30 Oct 2018 22:06:01 +0800 Subject: [PATCH] fix data race on migrate repository (#5224) --- models/repo.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/models/repo.go b/models/repo.go index 1bdd1581f2..3e18776046 100644 --- a/models/repo.go +++ b/models/repo.go @@ -1043,7 +1043,6 @@ func MigrateRepository(doer, u *User, opts MigrateRepoOptions) (*Repository, err if err = SyncReleasesWithTags(repo, gitRepo); err != nil { log.Error(4, "Failed to synchronize tags to releases for repository: %v", err) } - UpdateRepoIndexer(repo) } if err = repo.UpdateSize(); err != nil { @@ -1061,10 +1060,16 @@ func MigrateRepository(doer, u *User, opts MigrateRepoOptions) (*Repository, err } repo.IsMirror = true - return repo, UpdateRepository(repo, false) + err = UpdateRepository(repo, false) + } else { + repo, err = CleanUpMigrateInfo(repo) + } + + if err != nil && !repo.IsBare { + UpdateRepoIndexer(repo) } - return CleanUpMigrateInfo(repo) + return repo, err } // cleanUpMigrateGitConfig removes mirror info which prevents "push --all". -- 2.39.5