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 /routers | |
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 'routers')
-rw-r--r-- | routers/admin/admin.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/routers/admin/admin.go b/routers/admin/admin.go index 055b8f5a5e..71a22e1f9e 100644 --- a/routers/admin/admin.go +++ b/routers/admin/admin.go @@ -24,6 +24,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/process" "code.gitea.io/gitea/modules/queue" + repo_module "code.gitea.io/gitea/modules/repository" "code.gitea.io/gitea/modules/setting" "code.gitea.io/gitea/modules/timeutil" "code.gitea.io/gitea/services/mailer" @@ -150,6 +151,7 @@ func Dashboard(ctx *context.Context) { if op > 0 { var err error var success string + shutdownCtx := graceful.GetManager().ShutdownContext() switch Operation(op) { case cleanInactivateUser: @@ -160,25 +162,25 @@ func Dashboard(ctx *context.Context) { err = models.DeleteRepositoryArchives() case cleanMissingRepos: success = ctx.Tr("admin.dashboard.delete_missing_repos_success") - err = models.DeleteMissingRepositories(ctx.User) + err = repo_module.DeleteMissingRepositories(ctx.User) case gitGCRepos: success = ctx.Tr("admin.dashboard.git_gc_repos_success") - err = models.GitGcRepos() + err = repo_module.GitGcRepos(shutdownCtx) case syncSSHAuthorizedKey: success = ctx.Tr("admin.dashboard.resync_all_sshkeys_success") err = models.RewriteAllPublicKeys() case syncRepositoryUpdateHook: success = ctx.Tr("admin.dashboard.resync_all_hooks_success") - err = models.SyncRepositoryHooks() + err = repo_module.SyncRepositoryHooks(shutdownCtx) case reinitMissingRepository: success = ctx.Tr("admin.dashboard.reinit_missing_repos_success") - err = models.ReinitMissingRepositories() + err = repo_module.ReinitMissingRepositories() case syncExternalUsers: success = ctx.Tr("admin.dashboard.sync_external_users_started") go graceful.GetManager().RunWithShutdownContext(models.SyncExternalUsers) case gitFsck: success = ctx.Tr("admin.dashboard.git_fsck_started") - go graceful.GetManager().RunWithShutdownContext(models.GitFsck) + err = repo_module.GitFsck(shutdownCtx) case deleteGeneratedRepositoryAvatars: success = ctx.Tr("admin.dashboard.delete_generated_repository_avatars_success") err = models.RemoveRandomAvatars() |