From 4ca1d7547a2c32cc65ca23d1a7698d1a8c921d65 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Mon, 9 May 2022 00:46:32 +0800 Subject: Move some helper files out of models (#19355) * Move some helper files out of models * Some improvements Co-authored-by: delvh --- services/repository/repository.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'services/repository/repository.go') diff --git a/services/repository/repository.go b/services/repository/repository.go index 685a3c7601..6799ca586e 100644 --- a/services/repository/repository.go +++ b/services/repository/repository.go @@ -9,6 +9,8 @@ import ( "fmt" "code.gitea.io/gitea/models" + admin_model "code.gitea.io/gitea/models/admin" + "code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/organization" packages_model "code.gitea.io/gitea/models/packages" repo_model "code.gitea.io/gitea/models/repo" @@ -16,7 +18,7 @@ import ( "code.gitea.io/gitea/modules/log" "code.gitea.io/gitea/modules/notification" repo_module "code.gitea.io/gitea/modules/repository" - cfg "code.gitea.io/gitea/modules/setting" + "code.gitea.io/gitea/modules/setting" pull_service "code.gitea.io/gitea/services/pull" ) @@ -67,7 +69,7 @@ func PushCreateRepo(authUser, owner *user_model.User, repoName string) (*repo_mo repo, err := CreateRepository(authUser, owner, models.CreateRepoOptions{ Name: repoName, - IsPrivate: cfg.Repository.DefaultPushCreatePrivate, + IsPrivate: setting.Repository.DefaultPushCreatePrivate, }) if err != nil { return nil, err @@ -76,8 +78,10 @@ func PushCreateRepo(authUser, owner *user_model.User, repoName string) (*repo_mo return repo, nil } -// NewContext start repository service -func NewContext() error { +// Init start repository service +func Init() error { repo_module.LoadRepoConfig() + admin_model.RemoveAllWithNotice(db.DefaultContext, "Clean up temporary repository uploads", setting.Repository.Upload.TempPath) + admin_model.RemoveAllWithNotice(db.DefaultContext, "Clean up temporary repositories", repo_module.LocalCopyPath()) return initPushQueue() } -- cgit v1.2.3