summaryrefslogtreecommitdiffstats
path: root/models/repo.go
diff options
context:
space:
mode:
authorEthan Koenig <etk39@cornell.edu>2017-05-31 04:57:17 -0400
committerLunny Xiao <xiaolunwen@gmail.com>2017-05-31 16:57:17 +0800
commitbfb44f885468839259bc2ead999953cdd85654e1 (patch)
tree1b8b404133dad5ad4650d15a0a9acc6207fb916b /models/repo.go
parent0f5b399e351786254f48dc1e5ed3419c3153703f (diff)
downloadgitea-bfb44f885468839259bc2ead999953cdd85654e1.tar.gz
gitea-bfb44f885468839259bc2ead999953cdd85654e1.zip
Fix status table race condition (#1835)
Diffstat (limited to 'models/repo.go')
-rw-r--r--models/repo.go9
1 files changed, 3 insertions, 6 deletions
diff --git a/models/repo.go b/models/repo.go
index 9f5318e2f6..7aaeb6e0e7 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -1881,10 +1881,9 @@ func DeleteRepositoryArchives() error {
// DeleteOldRepositoryArchives deletes old repository archives.
func DeleteOldRepositoryArchives() {
- if taskStatusTable.IsRunning(archiveCleanup) {
+ if !taskStatusTable.StartIfNotRunning(archiveCleanup) {
return
}
- taskStatusTable.Start(archiveCleanup)
defer taskStatusTable.Stop(archiveCleanup)
log.Trace("Doing: ArchiveCleanup")
@@ -2025,10 +2024,9 @@ const (
// GitFsck calls 'git fsck' to check repository health.
func GitFsck() {
- if taskStatusTable.IsRunning(gitFsck) {
+ if !taskStatusTable.StartIfNotRunning(gitFsck) {
return
}
- taskStatusTable.Start(gitFsck)
defer taskStatusTable.Stop(gitFsck)
log.Trace("Doing: GitFsck")
@@ -2097,10 +2095,9 @@ func repoStatsCheck(checker *repoChecker) {
// CheckRepoStats checks the repository stats
func CheckRepoStats() {
- if taskStatusTable.IsRunning(checkRepos) {
+ if !taskStatusTable.StartIfNotRunning(checkRepos) {
return
}
- taskStatusTable.Start(checkRepos)
defer taskStatusTable.Stop(checkRepos)
log.Trace("Doing: CheckRepoStats")