Skip to content

Commit c0d9408

Browse files
committed
use new function to apply NoAutoTime
1 parent c52953b commit c0d9408

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

models/repo/update.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ func UpdateRepositoryCols(ctx context.Context, repo *Repository, cols ...string)
4646
return err
4747
}
4848

49+
// UpdateRepositoryColsNoAutoTime updates repository's columns and but applies time change automatically
50+
func UpdateRepositoryColsNoAutoTime(ctx context.Context, repo *Repository, cols ...string) error {
51+
_, err := db.GetEngine(ctx).ID(repo.ID).Cols(cols...).NoAutoTime().Update(repo)
52+
return err
53+
}
54+
4955
// ErrReachLimitOfRepo represents a "ReachLimitOfRepo" kind of error.
5056
type ErrReachLimitOfRepo struct {
5157
Limit int

routers/web/repo/view_home.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,11 @@ func prepareRecentlyPushedNewBranches(ctx *context.Context) {
224224
}
225225

226226
func updateContextRepoEmptyAndStatus(ctx *context.Context, empty bool, status repo_model.RepositoryStatus) {
227-
repo := ctx.Repo.Repository
228-
repo.IsEmpty = empty
229-
if repo.Status == repo_model.RepositoryReady || repo.Status == repo_model.RepositoryBroken {
230-
repo.Status = status // only handle ready and broken status, leave other status as-is
227+
ctx.Repo.Repository.IsEmpty = empty
228+
if ctx.Repo.Repository.Status == repo_model.RepositoryReady || ctx.Repo.Repository.Status == repo_model.RepositoryBroken {
229+
ctx.Repo.Repository.Status = status // only handle ready and broken status, leave other status as-is
231230
}
232-
if _, err := db.GetEngine(ctx).ID(repo.ID).Cols("is_empty", "status").NoAutoTime().Update(repo); err != nil {
231+
if err := repo_model.UpdateRepositoryColsNoAutoTime(ctx, ctx.Repo.Repository, "is_empty", "status"); err != nil {
233232
ctx.ServerError("updateContextRepoEmptyAndStatus: UpdateRepositoryCols", err)
234233
return
235234
}

0 commit comments

Comments
 (0)