summaryrefslogtreecommitdiffstats
path: root/models/repo.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 /models/repo.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 'models/repo.go')
-rw-r--r--models/repo.go15
1 files changed, 4 insertions, 11 deletions
diff --git a/models/repo.go b/models/repo.go
index e20bf90d97..fb7bbba1e1 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -43,9 +43,6 @@ var ItemsPerPage = 40
// NewRepoContext creates a new repository context
func NewRepoContext() {
unit.LoadUnitConfig()
-
- admin_model.RemoveAllWithNotice(db.DefaultContext, "Clean up temporary repository uploads", setting.Repository.Upload.TempPath)
- admin_model.RemoveAllWithNotice(db.DefaultContext, "Clean up temporary repositories", LocalCopyPath())
}
// CheckRepoUnitUser check whether user could visit the unit of this repository
@@ -527,7 +524,8 @@ func DecrementRepoForkNum(ctx context.Context, repoID int64) error {
return err
}
-func updateRepository(ctx context.Context, repo *repo_model.Repository, visibilityChanged bool) (err error) {
+// UpdateRepositoryCtx updates a repository with db context
+func UpdateRepositoryCtx(ctx context.Context, repo *repo_model.Repository, visibilityChanged bool) (err error) {
repo.LowerName = strings.ToLower(repo.Name)
if utf8.RuneCountInString(repo.Description) > 255 {
@@ -579,7 +577,7 @@ func updateRepository(ctx context.Context, repo *repo_model.Repository, visibili
}
for i := range forkRepos {
forkRepos[i].IsPrivate = repo.IsPrivate || repo.Owner.Visibility == api.VisibleTypePrivate
- if err = updateRepository(ctx, forkRepos[i], true); err != nil {
+ if err = UpdateRepositoryCtx(ctx, forkRepos[i], true); err != nil {
return fmt.Errorf("updateRepository[%d]: %v", forkRepos[i].ID, err)
}
}
@@ -588,11 +586,6 @@ func updateRepository(ctx context.Context, repo *repo_model.Repository, visibili
return nil
}
-// UpdateRepositoryCtx updates a repository with db context
-func UpdateRepositoryCtx(ctx context.Context, repo *repo_model.Repository, visibilityChanged bool) error {
- return updateRepository(ctx, repo, visibilityChanged)
-}
-
// UpdateRepository updates a repository
func UpdateRepository(repo *repo_model.Repository, visibilityChanged bool) (err error) {
ctx, committer, err := db.TxContext()
@@ -601,7 +594,7 @@ func UpdateRepository(repo *repo_model.Repository, visibilityChanged bool) (err
}
defer committer.Close()
- if err = updateRepository(ctx, repo, visibilityChanged); err != nil {
+ if err = UpdateRepositoryCtx(ctx, repo, visibilityChanged); err != nil {
return fmt.Errorf("updateRepository: %v", err)
}