Skip to content

Commit 925abb9

Browse files
committed
Only git operations should update the updated_unix column in repository table
1 parent 6bd8fe5 commit 925abb9

File tree

12 files changed

+16
-21
lines changed

12 files changed

+16
-21
lines changed

models/actions/run.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ func (run *ActionRun) IsSchedule() bool {
171171

172172
func updateRepoRunsNumbers(ctx context.Context, repo *repo_model.Repository) error {
173173
_, err := db.GetEngine(ctx).ID(repo.ID).
174+
NoAutoTime().
174175
SetExpr("num_action_runs",
175176
builder.Select("count(*)").From("action_run").
176177
Where(builder.Eq{"repo_id": repo.ID}),

models/repo/transfer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ func CreatePendingRepositoryTransfer(ctx context.Context, doer, newOwner *user_m
249249
}
250250

251251
repo.Status = RepositoryPendingTransfer
252-
if err := UpdateRepositoryCols(ctx, repo, "status"); err != nil {
252+
if err := UpdateRepositoryColsNoAutoTime(ctx, repo, "status"); err != nil {
253253
return err
254254
}
255255

models/repo/update.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func UpdateRepositoryOwnerNames(ctx context.Context, ownerID int64, ownerName st
2525
}
2626
defer committer.Close()
2727

28-
if _, err := db.GetEngine(ctx).Where("owner_id = ?", ownerID).Cols("owner_name").Update(&Repository{
28+
if _, err := db.GetEngine(ctx).Where("owner_id = ?", ownerID).Cols("owner_name").NoAutoTime().Update(&Repository{
2929
OwnerName: ownerName,
3030
}); err != nil {
3131
return err

routers/private/hook_post_receive.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ func HookPostReceive(ctx *gitea_context.PrivateContext) {
220220
}
221221

222222
if len(cols) > 0 {
223-
if err := repo_model.UpdateRepositoryCols(ctx, repo, cols...); err != nil {
223+
if err := repo_model.UpdateRepositoryColsNoAutoTime(ctx, repo, cols...); err != nil {
224224
log.Error("Failed to Update: %s/%s Error: %v", ownerName, repoName, err)
225225
ctx.JSON(http.StatusInternalServerError, private.HookPostReceiveResult{
226226
Err: fmt.Sprintf("Failed to Update: %s/%s Error: %v", ownerName, repoName, err),

routers/web/repo/editor.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -376,12 +376,6 @@ func editFilePost(ctx *context.Context, form forms.EditRepoFileForm, isNewFile b
376376
}
377377
}
378378

379-
if ctx.Repo.Repository.IsEmpty {
380-
if isEmpty, err := ctx.Repo.GitRepo.IsEmpty(); err == nil && !isEmpty {
381-
_ = repo_model.UpdateRepositoryCols(ctx, &repo_model.Repository{ID: ctx.Repo.Repository.ID, IsEmpty: false}, "is_empty")
382-
}
383-
}
384-
385379
redirectForCommitChoice(ctx, form.CommitChoice, branchName, form.TreePath)
386380
}
387381

routers/web/repo/wiki.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ func findWikiRepoCommit(ctx *context.Context) (*git.Repository, *git.Commit, err
109109
return wikiGitRepo, nil, errBranch
110110
}
111111
// update the default branch in the database
112-
errDb := repo_model.UpdateRepositoryCols(ctx, &repo_model.Repository{ID: ctx.Repo.Repository.ID, DefaultWikiBranch: gitRepoDefaultBranch}, "default_wiki_branch")
112+
errDb := repo_model.UpdateRepositoryColsNoAutoTime(ctx, &repo_model.Repository{ID: ctx.Repo.Repository.ID, DefaultWikiBranch: gitRepoDefaultBranch}, "default_wiki_branch")
113113
if errDb != nil {
114114
return wikiGitRepo, nil, errDb
115115
}

services/migrations/gitea_uploader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ func (g *GiteaLocalUploader) CreateRepo(ctx context.Context, repo *base.Reposito
148148
return err
149149
}
150150
g.repo.ObjectFormatName = objectFormat.Name()
151-
return repo_model.UpdateRepositoryCols(ctx, g.repo, "object_format_name")
151+
return repo_model.UpdateRepositoryColsNoAutoTime(ctx, g.repo, "object_format_name")
152152
}
153153

154154
// Close closes this uploader

services/mirror/mirror_pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func UpdateAddress(ctx context.Context, m *repo_model.Mirror, addr string) error
7171
// erase authentication before storing in database
7272
u.User = nil
7373
m.Repo.OriginalURL = u.String()
74-
return repo_model.UpdateRepositoryCols(ctx, m.Repo, "original_url")
74+
return repo_model.UpdateRepositoryColsNoAutoTime(ctx, m.Repo, "original_url")
7575
}
7676

7777
// mirrorSyncResult contains information of a updated reference.

services/repository/avatar.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func UploadAvatar(ctx context.Context, repo *repo_model.Repository, data []byte)
4040
// Users can upload the same image to other repo - prefix it with ID
4141
// Then repo will be removed - only it avatar file will be removed
4242
repo.Avatar = newAvatar
43-
if err := repo_model.UpdateRepositoryCols(ctx, repo, "avatar"); err != nil {
43+
if err := repo_model.UpdateRepositoryColsNoAutoTime(ctx, repo, "avatar"); err != nil {
4444
return fmt.Errorf("UploadAvatar: Update repository avatar: %w", err)
4545
}
4646

@@ -77,7 +77,7 @@ func DeleteAvatar(ctx context.Context, repo *repo_model.Repository) error {
7777
defer committer.Close()
7878

7979
repo.Avatar = ""
80-
if err := repo_model.UpdateRepositoryCols(ctx, repo, "avatar"); err != nil {
80+
if err := repo_model.UpdateRepositoryColsNoAutoTime(ctx, repo, "avatar"); err != nil {
8181
return fmt.Errorf("DeleteAvatar: Update repository avatar: %w", err)
8282
}
8383

@@ -112,5 +112,5 @@ func generateAvatar(ctx context.Context, templateRepo, generateRepo *repo_model.
112112
return err
113113
}
114114

115-
return repo_model.UpdateRepositoryCols(ctx, generateRepo, "avatar")
115+
return repo_model.UpdateRepositoryColsNoAutoTime(ctx, generateRepo, "avatar")
116116
}

services/repository/repository.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ func updateRepository(ctx context.Context, repo *repo_model.Repository, visibili
205205

206206
e := db.GetEngine(ctx)
207207

208-
if _, err = e.ID(repo.ID).AllCols().Update(repo); err != nil {
208+
if _, err = e.ID(repo.ID).NoAutoTime().AllCols().Update(repo); err != nil {
209209
return fmt.Errorf("update: %w", err)
210210
}
211211

0 commit comments

Comments
 (0)