diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-10-17 07:29:26 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-17 07:29:26 +0800 |
commit | f860a6d2e4177ed4f4c2a58a07882bd00a1a52ad (patch) | |
tree | 93abb2f354576e50c87d70b0b4bb46369fb3a1f1 /models/repo.go | |
parent | 5d3dbffa150d832d2f9aedd9f90ca91178a95f9c (diff) | |
download | gitea-f860a6d2e4177ed4f4c2a58a07882bd00a1a52ad.tar.gz gitea-f860a6d2e4177ed4f4c2a58a07882bd00a1a52ad.zip |
Add system setting table with cache and also add cache supports for user setting (#18058)
Diffstat (limited to 'models/repo.go')
-rw-r--r-- | models/repo.go | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/models/repo.go b/models/repo.go index 94e6249842..65159f14af 100644 --- a/models/repo.go +++ b/models/repo.go @@ -22,6 +22,7 @@ import ( access_model "code.gitea.io/gitea/models/perm/access" project_model "code.gitea.io/gitea/models/project" repo_model "code.gitea.io/gitea/models/repo" + system_model "code.gitea.io/gitea/models/system" "code.gitea.io/gitea/models/unit" user_model "code.gitea.io/gitea/models/user" "code.gitea.io/gitea/models/webhook" @@ -32,9 +33,13 @@ import ( "xorm.io/builder" ) -// NewRepoContext creates a new repository context -func NewRepoContext() { +// ItemsPerPage maximum items per page in forks, watchers and stars of a repo +var ItemsPerPage = 40 + +// Init initialize model +func Init() error { unit.LoadUnitConfig() + return system_model.Init() } // DeleteRepository deletes a repository for a user or organization. @@ -267,36 +272,36 @@ func DeleteRepository(doer *user_model.User, uid, repoID int64) error { // Remove repository files. repoPath := repo.RepoPath() - admin_model.RemoveAllWithNotice(db.DefaultContext, "Delete repository files", repoPath) + system_model.RemoveAllWithNotice(db.DefaultContext, "Delete repository files", repoPath) // Remove wiki files if repo.HasWiki() { - admin_model.RemoveAllWithNotice(db.DefaultContext, "Delete repository wiki", repo.WikiPath()) + system_model.RemoveAllWithNotice(db.DefaultContext, "Delete repository wiki", repo.WikiPath()) } // Remove archives for _, archive := range archivePaths { - admin_model.RemoveStorageWithNotice(db.DefaultContext, storage.RepoArchives, "Delete repo archive file", archive) + system_model.RemoveStorageWithNotice(db.DefaultContext, storage.RepoArchives, "Delete repo archive file", archive) } // Remove lfs objects for _, lfsObj := range lfsPaths { - admin_model.RemoveStorageWithNotice(db.DefaultContext, storage.LFS, "Delete orphaned LFS file", lfsObj) + system_model.RemoveStorageWithNotice(db.DefaultContext, storage.LFS, "Delete orphaned LFS file", lfsObj) } // Remove issue attachment files. for _, attachment := range attachmentPaths { - admin_model.RemoveStorageWithNotice(db.DefaultContext, storage.Attachments, "Delete issue attachment", attachment) + system_model.RemoveStorageWithNotice(db.DefaultContext, storage.Attachments, "Delete issue attachment", attachment) } // Remove release attachment files. for _, releaseAttachment := range releaseAttachments { - admin_model.RemoveStorageWithNotice(db.DefaultContext, storage.Attachments, "Delete release attachment", releaseAttachment) + system_model.RemoveStorageWithNotice(db.DefaultContext, storage.Attachments, "Delete release attachment", releaseAttachment) } // Remove attachment with no issue_id and release_id. for _, newAttachment := range newAttachmentPaths { - admin_model.RemoveStorageWithNotice(db.DefaultContext, storage.Attachments, "Delete issue attachment", newAttachment) + system_model.RemoveStorageWithNotice(db.DefaultContext, storage.Attachments, "Delete issue attachment", newAttachment) } if len(repo.Avatar) > 0 { |