mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Refactor Pull Mirror and fix out-of-sync bugs (#24732)
The "mirror" table and "repository" table might be out-of-sync in some cases. It means that "IsMirror=true" but "Mirror=nil" This PR removes unnecessary "Mirror" field, rename "Mirror" to "PullMirror" and fix nil panic bug. Screenshot of changed templates:  
This commit is contained in:
@@ -61,7 +61,6 @@ type Repository struct {
|
||||
RepoLink string
|
||||
CloneLink repo_model.CloneLink
|
||||
CommitsCount int64
|
||||
Mirror *repo_model.Mirror
|
||||
|
||||
PullRequest *PullRequest
|
||||
}
|
||||
@@ -380,13 +379,9 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) {
|
||||
ctx.Data["Permission"] = &ctx.Repo.Permission
|
||||
|
||||
if repo.IsMirror {
|
||||
ctx.Repo.Mirror, err = repo_model.GetMirrorByRepoID(ctx, repo.ID)
|
||||
pullMirror, err := repo_model.GetMirrorByRepoID(ctx, repo.ID)
|
||||
if err == nil {
|
||||
ctx.Repo.Mirror.Repo = repo
|
||||
ctx.Data["IsPullMirror"] = true
|
||||
ctx.Data["MirrorEnablePrune"] = ctx.Repo.Mirror.EnablePrune
|
||||
ctx.Data["MirrorInterval"] = ctx.Repo.Mirror.Interval
|
||||
ctx.Data["Mirror"] = ctx.Repo.Mirror
|
||||
ctx.Data["PullMirror"] = pullMirror
|
||||
} else if err != repo_model.ErrMirrorNotExist {
|
||||
ctx.ServerError("GetMirrorByRepoID", err)
|
||||
return
|
||||
|
Reference in New Issue
Block a user