You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
forgejo/models/repo
zeripath 03df7d0452
Check Mirror exists before linking its Repo (#20840)
In MirrorRepositoryList.loadAttributes there is some code to load the Mirror entries
from the database. This assumes that every Repository which has IsMirror set has
a Mirror associated in the DB. This association is incorrect in the case of
Mirror repository under creation when there is no Mirror entry in the DB until
completion.

Unfortunately LoadAttributes makes this incorrect assumption and presumes that a
Mirror will always be loaded. This then causes a panic.

This PR simply double checks if there a Mirror before attempting to link back to
its Repo. Unfortunately it should be expected that there may be other cases where
this incorrect assumption causes further problems.

Fix #20804

Signed-off-by: Andrew Thornton <art27@cantab.net>

Signed-off-by: Andrew Thornton <art27@cantab.net>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
2 years ago
..
archiver.go Add more linters to improve code readability (#19989) 2 years ago
attachment.go Add migrate repo archiver and packages storage support on command line (#20757) 2 years ago
attachment_test.go Move some repository related code into sub package (#19711) 2 years ago
avatar.go Move almost all functions' parameter db.Engine to context.Context (#19748) 2 years ago
collaboration.go Move some code into models/git (#19879) 2 years ago
collaboration_test.go Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
fork.go Feature: Find files in repo (#15028) 2 years ago
fork_test.go Move some repository related code into sub package (#19711) 2 years ago
git.go Move repository model into models/repo (#17933) 3 years ago
issue.go Prevent deadlock in create issue (#17970) 3 years ago
language_stats.go Move almost all functions' parameter db.Engine to context.Context (#19748) 2 years ago
main_test.go Feature: Find files in repo (#15028) 2 years ago
mirror.go Check Mirror exists before linking its Repo (#20840) 2 years ago
pushmirror.go Add new API endpoints for push mirrors management (#19841) 2 years ago
pushmirror_test.go Add new API endpoints for push mirrors management (#19841) 2 years ago
redirect.go Some repository refactors (#17950) 3 years ago
redirect_test.go Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
repo.go Adjust transaction handling via db.Context (#20031) 2 years ago
repo_indexer.go Move almost all functions' parameter db.Engine to context.Context (#19748) 2 years ago
repo_list.go Add migrate repo archiver and packages storage support on command line (#20757) 2 years ago
repo_list_test.go Move some repository related code into sub package (#19711) 2 years ago
repo_test.go Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
repo_unit.go Custom regexp external issues (#17624) 2 years ago
star.go Move almost all functions' parameter db.Engine to context.Context (#19748) 2 years ago
star_test.go Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
topic.go Move almost all functions' parameter db.Engine to context.Context (#19748) 2 years ago
topic_test.go Move some repository related code into sub package (#19711) 2 years ago
update.go Move some repository related code into sub package (#19711) 2 years ago
user_repo.go Add issue filter for Author (#20578) 2 years ago
user_repo_test.go Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
watch.go Move almost all functions' parameter db.Engine to context.Context (#19748) 2 years ago
watch_test.go Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
wiki.go Move repository model into models/repo (#17933) 3 years ago
wiki_test.go Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago