aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2018-10-30 22:06:01 +0800
committertechknowlogick <hello@techknowlogick.com>2018-10-30 10:06:01 -0400
commite61c6cd3dbc756b363f6e5441d67e207605c1dc0 (patch)
treeb8c061f37cbf1f898d1f2f2ac499a60aa0503992
parent0ba57949e41935ed68b7278b493bf7bd1a272331 (diff)
downloadgitea-e61c6cd3dbc756b363f6e5441d67e207605c1dc0.tar.gz
gitea-e61c6cd3dbc756b363f6e5441d67e207605c1dc0.zip
fix data race on migrate repository (#5224)
-rw-r--r--models/repo.go11
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".