Skip to content

Commit 63b3a33

Browse files
GiteaBotchangchaishiwxiaoguang
authored
fix empty repo updated time (#33120) (#33124)
Backport #33120 by changchaishi fixes #33119 Co-authored-by: Chai-Shi <[email protected]> Co-authored-by: wxiaoguang <[email protected]>
1 parent 9899989 commit 63b3a33

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Diff for: models/repo/update.go

+6
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

Diff for: routers/web/repo/view_home.go

+4-1
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,14 @@ func prepareRecentlyPushedNewBranches(ctx *context.Context) {
224224
}
225225

226226
func updateContextRepoEmptyAndStatus(ctx *context.Context, empty bool, status repo_model.RepositoryStatus) {
227+
if ctx.Repo.Repository.IsEmpty == empty && ctx.Repo.Repository.Status == status {
228+
return
229+
}
227230
ctx.Repo.Repository.IsEmpty = empty
228231
if ctx.Repo.Repository.Status == repo_model.RepositoryReady || ctx.Repo.Repository.Status == repo_model.RepositoryBroken {
229232
ctx.Repo.Repository.Status = status // only handle ready and broken status, leave other status as-is
230233
}
231-
if err := repo_model.UpdateRepositoryCols(ctx, ctx.Repo.Repository, "is_empty", "status"); err != nil {
234+
if err := repo_model.UpdateRepositoryColsNoAutoTime(ctx, ctx.Repo.Repository, "is_empty", "status"); err != nil {
232235
ctx.ServerError("updateContextRepoEmptyAndStatus: UpdateRepositoryCols", err)
233236
return
234237
}

0 commit comments

Comments
 (0)