diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2018-10-30 22:06:01 +0800 |
---|---|---|
committer | techknowlogick <hello@techknowlogick.com> | 2018-10-30 10:06:01 -0400 |
commit | e61c6cd3dbc756b363f6e5441d67e207605c1dc0 (patch) | |
tree | b8c061f37cbf1f898d1f2f2ac499a60aa0503992 | |
parent | 0ba57949e41935ed68b7278b493bf7bd1a272331 (diff) | |
download | gitea-e61c6cd3dbc756b363f6e5441d67e207605c1dc0.tar.gz gitea-e61c6cd3dbc756b363f6e5441d67e207605c1dc0.zip |
fix data race on migrate repository (#5224)
-rw-r--r-- | models/repo.go | 11 |
1 files 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". |