diff options
author | Gusted <williamzijl7@hotmail.com> | 2022-05-04 10:09:42 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-04 12:09:42 +0200 |
commit | 3114cd30b817692556306ce6261ace2b58c54b76 (patch) | |
tree | c26e7e748a795197c76ca93eee0013584d4f4096 /models/task.go | |
parent | 9c04da37d0bcb51ef0c20baeeea48c48eda99ff0 (diff) | |
download | gitea-3114cd30b817692556306ce6261ace2b58c54b76.tar.gz gitea-3114cd30b817692556306ce6261ace2b58c54b76.zip |
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
Diffstat (limited to 'models/task.go')
-rw-r--r-- | models/task.go | 12 |
1 files changed, 6 insertions, 6 deletions
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 |