forked from forgejo/forgejo
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>
This commit is contained in:
parent
d4834071da
commit
4ca1d7547a
23 changed files with 108 additions and 107 deletions
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue