]> source.dussan.org Git - gitea.git/commitdiff
fix data race on migrate repository (#5224)
authorLunny Xiao <xiaolunwen@gmail.com>
Tue, 30 Oct 2018 14:06:01 +0000 (22:06 +0800)
committertechknowlogick <hello@techknowlogick.com>
Tue, 30 Oct 2018 14:06:01 +0000 (10:06 -0400)
models/repo.go

index 1bdd1581f2eec7e79908205b23318f3e560a24fc..3e18776046062d3df9597694b4845cc267e91018 100644 (file)
@@ -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".