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:
parent
b9fad73e9f
commit
99283415bc
6 changed files with 45 additions and 33 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue