summaryrefslogtreecommitdiffstats
path: root/services/repository/repository.go
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-05-09 00:46:32 +0800
committerGitHub <noreply@github.com>2022-05-08 18:46:32 +0200
commit4ca1d7547a2c32cc65ca23d1a7698d1a8c921d65 (patch)
treefee132403adea441987ce25809c764e00fd962cd /services/repository/repository.go
parentd4834071da9ce010fd4677ef339c598dd23dc130 (diff)
downloadgitea-4ca1d7547a2c32cc65ca23d1a7698d1a8c921d65.tar.gz
gitea-4ca1d7547a2c32cc65ca23d1a7698d1a8c921d65.zip
Move some helper files out of models (#19355)
* Move some helper files out of models * Some improvements Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'services/repository/repository.go')
-rw-r--r--services/repository/repository.go12
1 files changed, 8 insertions, 4 deletions
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()
}