diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2020-01-21 04:01:19 +0800 |
---|---|---|
committer | zeripath <art27@cantab.net> | 2020-01-20 20:01:19 +0000 |
commit | d92781bf941972761177ac9e07441f8893758fd3 (patch) | |
tree | d5d00f8f42fc75ee497bfd8cd52d3b431f1d9b67 /modules/cron/cron.go | |
parent | 27c6b8fc07eab2dd579b94cd92136738ace61706 (diff) | |
download | gitea-d92781bf941972761177ac9e07441f8893758fd3.tar.gz gitea-d92781bf941972761177ac9e07441f8893758fd3.zip |
Refactor repository check and sync functions (#9854)
Move more general repository functions out of models/repo.go
Diffstat (limited to 'modules/cron/cron.go')
-rw-r--r-- | modules/cron/cron.go | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/modules/cron/cron.go b/modules/cron/cron.go index f4511a8e79..692642e4ce 100644 --- a/modules/cron/cron.go +++ b/modules/cron/cron.go @@ -13,6 +13,7 @@ import ( "code.gitea.io/gitea/modules/graceful" "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/migrations" + repo_module "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/sync" mirror_service "code.gitea.io/gitea/services/mirror" @@ -69,14 +70,22 @@ func NewContext() { } } if setting.Cron.RepoHealthCheck.Enabled { - entry, err = c.AddFunc("Repository health check", setting.Cron.RepoHealthCheck.Schedule, WithUnique(gitFsck, models.GitFsck)) + entry, err = c.AddFunc("Repository health check", setting.Cron.RepoHealthCheck.Schedule, WithUnique(gitFsck, func(ctx context.Context) { + if err := repo_module.GitFsck(ctx); err != nil { + log.Error("GitFsck: %s", err) + } + })) if err != nil { log.Fatal("Cron[Repository health check]: %v", err) } if setting.Cron.RepoHealthCheck.RunAtStart { entry.Prev = time.Now() entry.ExecTimes++ - go WithUnique(gitFsck, models.GitFsck)() + go WithUnique(gitFsck, func(ctx context.Context) { + if err := repo_module.GitFsck(ctx); err != nil { + log.Error("GitFsck: %s", err) + } + })() } } if setting.Cron.CheckRepoStats.Enabled { |