Skip to content

Commit 5799cd9

Browse files
author
Gusted
committed
Only check for non-finished migrating task
- Only check if a non-finished migrating task exists for a mirror before fetching the mirror details from the database. - Resolves go-gitea#19600 - Regression: go-gitea#19588
1 parent cc3016f commit 5799cd9

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

models/task.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ func GetMigratingTask(repoID int64) (*Task, error) {
181181
return &task, nil
182182
}
183183

184-
// HasMigratingTask returns if migrating task exist for repo.
185-
func HasMigratingTask(repoID int64) (bool, error) {
186-
return db.GetEngine(db.DefaultContext).Exist(&Task{
187-
RepoID: repoID,
188-
Type: structs.TaskTypeMigrateRepo,
189-
})
184+
// HasNonFinishedMigratingTask returns if a non-finished migrating task exist for the repo.
185+
func HasNonFinishedMigratingTask(repoID int64) (bool, error) {
186+
return db.GetEngine(db.DefaultContext).
187+
Where("repo_id=? AND type=? AND status<>?", repoID, structs.TaskTypeMigrateRepo, structs.TaskStatusFinished).
188+
Table("task").
189+
Exist()
190190
}
191191

192192
// GetMigratingTaskByID returns the migrating task by repo's id

modules/context/repo.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) {
373373

374374
// Check if there's a migrating task.
375375
// If it does exist, don't fetch the Mirror from the database as it doesn't exist yet.
376-
hasTask, err := models.HasMigratingTask(repo.ID)
376+
hasTask, err := models.HasNonFinishedMigratingTask(repo.ID)
377377
if err != nil {
378378
ctx.ServerError("GetMirrorByRepoID", err)
379379
return

0 commit comments

Comments
 (0)