mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Move db related basic functions to models/db (#17075)
* Move db related basic functions to models/db * Fix lint * Fix lint * Fix test * Fix lint * Fix lint * revert unnecessary change * Fix test * Fix wrong replace string * Use *Context * Correct committer spelling and fix wrong replaced words Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"time"
|
||||
|
||||
"code.gitea.io/gitea/models"
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
@@ -22,8 +23,8 @@ import (
|
||||
func GitFsck(ctx context.Context, timeout time.Duration, args []string) error {
|
||||
log.Trace("Doing: GitFsck")
|
||||
|
||||
if err := models.Iterate(
|
||||
models.DefaultDBContext(),
|
||||
if err := db.Iterate(
|
||||
db.DefaultContext(),
|
||||
new(models.Repository),
|
||||
builder.Expr("id>0 AND is_fsck_enabled=?", true),
|
||||
func(idx int, bean interface{}) error {
|
||||
@@ -57,8 +58,8 @@ func GitGcRepos(ctx context.Context, timeout time.Duration, args ...string) erro
|
||||
log.Trace("Doing: GitGcRepos")
|
||||
args = append([]string{"gc"}, args...)
|
||||
|
||||
if err := models.Iterate(
|
||||
models.DefaultDBContext(),
|
||||
if err := db.Iterate(
|
||||
db.DefaultContext(),
|
||||
new(models.Repository),
|
||||
builder.Gt{"id": 0},
|
||||
func(idx int, bean interface{}) error {
|
||||
@@ -93,7 +94,7 @@ func GitGcRepos(ctx context.Context, timeout time.Duration, args ...string) erro
|
||||
}
|
||||
|
||||
// Now update the size of the repository
|
||||
if err := repo.UpdateSize(models.DefaultDBContext()); err != nil {
|
||||
if err := repo.UpdateSize(db.DefaultContext()); err != nil {
|
||||
log.Error("Updating size as part of garbage collection failed for %v. Stdout: %s\nError: %v", repo, stdout, err)
|
||||
desc := fmt.Sprintf("Updating size as part of garbage collection failed for %s. Stdout: %s\nError: %v", repo.RepoPath(), stdout, err)
|
||||
if err = models.CreateRepositoryNotice(desc); err != nil {
|
||||
@@ -114,8 +115,8 @@ func GitGcRepos(ctx context.Context, timeout time.Duration, args ...string) erro
|
||||
|
||||
func gatherMissingRepoRecords(ctx context.Context) ([]*models.Repository, error) {
|
||||
repos := make([]*models.Repository, 0, 10)
|
||||
if err := models.Iterate(
|
||||
models.DefaultDBContext(),
|
||||
if err := db.Iterate(
|
||||
db.DefaultContext(),
|
||||
new(models.Repository),
|
||||
builder.Gt{"id": 0},
|
||||
func(idx int, bean interface{}) error {
|
||||
|
Reference in New Issue
Block a user