summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorGusted <williamzijl7@hotmail.com>2022-05-03 15:55:17 +0200
committerGitHub <noreply@github.com>2022-05-03 15:55:17 +0200
commit982b726b0829686cc49543c6aee696a4b24d833f (patch)
tree99e9ed4f7d33885915c6e59560c374f60f6fbdd0 /modules
parentMove user password verification after checking his groups on ldap auth (#19587) (diff)
downloadforgejo-982b726b0829686cc49543c6aee696a4b24d833f.tar.xz
forgejo-982b726b0829686cc49543c6aee696a4b24d833f.zip
Don't fetch Mirror when it's migrating (#19588)
- When a repository is still being migrated, don't try to fetch the Mirror from the database. Instead skip it. This allows to visit repositories that are still being migrated and were configured to be mirrored. - Resolves #19585 - Regression: #19295 Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'modules')
-rw-r--r--modules/context/repo.go19
1 files changed, 14 insertions, 5 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go
index b2c9a21f8e..c5e3a69e5c 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -370,15 +370,24 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) {
ctx.Data["Permission"] = &ctx.Repo.Permission
if repo.IsMirror {
- var err error
- ctx.Repo.Mirror, err = repo_model.GetMirrorByRepoID(repo.ID)
+
+ // Check if there's a migrating task.
+ // If it does exist, don't fetch the Mirror from the database as it doesn't exist yet.
+ hasTask, err := models.HasMigratingTask(repo.ID)
if err != nil {
ctx.ServerError("GetMirrorByRepoID", err)
return
}
- ctx.Data["MirrorEnablePrune"] = ctx.Repo.Mirror.EnablePrune
- ctx.Data["MirrorInterval"] = ctx.Repo.Mirror.Interval
- ctx.Data["Mirror"] = ctx.Repo.Mirror
+ if !hasTask {
+ ctx.Repo.Mirror, err = repo_model.GetMirrorByRepoID(repo.ID)
+ if err != nil {
+ ctx.ServerError("GetMirrorByRepoID", err)
+ return
+ }
+ ctx.Data["MirrorEnablePrune"] = ctx.Repo.Mirror.EnablePrune
+ ctx.Data["MirrorInterval"] = ctx.Repo.Mirror.Interval
+ ctx.Data["Mirror"] = ctx.Repo.Mirror
+ }
}
pushMirrors, err := repo_model.GetPushMirrorsByRepoID(repo.ID)