diff options
author | zeripath <art27@cantab.net> | 2022-06-02 18:56:32 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-02 18:56:32 +0200 |
commit | e32ab429ffd863f26d2ea884307bcf2c7064d209 (patch) | |
tree | f1b52fc46b6e6bab0cbf59b7056d3783d20851c0 /modules | |
parent | update documents (#19868) (diff) | |
download | forgejo-e32ab429ffd863f26d2ea884307bcf2c7064d209.tar.xz forgejo-e32ab429ffd863f26d2ea884307bcf2c7064d209.zip |
Prevent NPE on update mirror settings (#19864)
A `repo_model.Mirror` repository field (`.Repo`) will not automatically
be set, but is used without checking in mirror_pull.go:UpdateAddress.
This will cause an NPE.
This PR changes UpdateAddress to use the helper function GetRepository()
helping prevent future NPEs but also changes modules/context/repo.go to
ensure that the Mirror.Repo is set.
Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: techknowlogick <techknowlogick@gitea.io>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/context/repo.go | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go index 539b111f15..df3fe4e74d 100644 --- a/modules/context/repo.go +++ b/modules/context/repo.go @@ -391,7 +391,7 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) { ctx.ServerError("GetMirrorByRepoID", err) return } - ctx.Repo.Mirror.Repo = ctx.Repo.Repository + ctx.Repo.Mirror.Repo = repo ctx.Data["MirrorEnablePrune"] = ctx.Repo.Mirror.EnablePrune ctx.Data["MirrorInterval"] = ctx.Repo.Mirror.Interval ctx.Data["Mirror"] = ctx.Repo.Mirror |