mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-25 11:22:16 +00:00
Refactor repository check and sync functions (#9854)
Move more general repository functions out of models/repo.go
This commit is contained in:
parent
27c6b8fc07
commit
d92781bf94
12 changed files with 313 additions and 210 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue