Skip to content

Commit c52953b

Browse files
committed
use NoAutoTime to update db
1 parent de3e3ef commit c52953b

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

routers/web/repo/view_home.go

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -224,25 +224,14 @@ func prepareRecentlyPushedNewBranches(ctx *context.Context) {
224224
}
225225

226226
func updateContextRepoEmptyAndStatus(ctx *context.Context, empty bool, status repo_model.RepositoryStatus) {
227-
needsUpdate := false
228-
229-
if empty != ctx.Repo.Repository.IsEmpty {
230-
ctx.Repo.Repository.IsEmpty = empty
231-
needsUpdate = true
232-
}
233-
234-
if ctx.Repo.Repository.Status == repo_model.RepositoryReady || ctx.Repo.Repository.Status == repo_model.RepositoryBroken {
235-
if status != ctx.Repo.Repository.Status {
236-
ctx.Repo.Repository.Status = status // only handle ready and broken status, leave other status as-is
237-
needsUpdate = true
238-
}
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
239231
}
240-
241-
if needsUpdate {
242-
if err := repo_model.UpdateRepositoryCols(ctx, ctx.Repo.Repository, "is_empty", "status"); err != nil {
243-
ctx.ServerError("updateContextRepoEmptyAndStatus: UpdateRepositoryCols", err)
244-
return
245-
}
232+
if _, err := db.GetEngine(ctx).ID(repo.ID).Cols("is_empty", "status").NoAutoTime().Update(repo); err != nil {
233+
ctx.ServerError("updateContextRepoEmptyAndStatus: UpdateRepositoryCols", err)
234+
return
246235
}
247236
}
248237

0 commit comments

Comments
 (0)