From 3114cd30b817692556306ce6261ace2b58c54b76 Mon Sep 17 00:00:00 2001 From: Gusted Date: Wed, 4 May 2022 10:09:42 +0000 Subject: Only check for non-finished migrating task (#19601) * 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 #19600 - Regression: #19588 * Clarify function --- models/task.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'models/task.go') diff --git a/models/task.go b/models/task.go index 0720d28610..5528573ca5 100644 --- a/models/task.go +++ b/models/task.go @@ -181,12 +181,12 @@ func GetMigratingTask(repoID int64) (*Task, error) { return &task, nil } -// HasMigratingTask returns if migrating task exist for repo. -func HasMigratingTask(repoID int64) (bool, error) { - return db.GetEngine(db.DefaultContext).Exist(&Task{ - RepoID: repoID, - Type: structs.TaskTypeMigrateRepo, - }) +// HasFinishedMigratingTask returns if a finished migration task exists for the repo. +func HasFinishedMigratingTask(repoID int64) (bool, error) { + return db.GetEngine(db.DefaultContext). + Where("repo_id=? AND type=? AND status=?", repoID, structs.TaskTypeMigrateRepo, structs.TaskStatusFinished). + Table("task"). + Exist() } // GetMigratingTaskByID returns the migrating task by repo's id -- cgit v1.2.3