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
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
..
admin Add more linters to improve code readability (#19989) 2 years ago
appstate Sync gitea app path for git hooks and authorized keys when starting (#17335) 3 years ago
asymkey Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
auth Fix panic when an invalid oauth2 name is passed (#20820) 2 years ago
avatars format with gofumpt (#18184) 2 years ago
db Add migrate repo archiver and packages storage support on command line (#20757) 2 years ago
fixtures Exclude Archived repos from Dashboard Milestones (#19882) 2 years ago
foreignreference Store the foreign ID of issues during migration (#18446) 2 years ago
git Add migrate repo archiver and packages storage support on command line (#20757) 2 years ago
issues Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
migrations Add badge capabilities to users (#20607) 2 years ago
organization Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
packages Add support for Pub packages (#20560) 2 years ago
perm Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
project Add option to purge users (#18064) 2 years ago
pull Delete related PullAutoMerge and ReviewState on User/Repo Deletion (#19649) 2 years ago
repo Check Mirror exists before linking its Repo (#20840) 2 years ago
unit Add more linters to improve code readability (#19989) 2 years ago
unittest Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
user Add badge capabilities to users (#20607) 2 years ago
webhook Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
action.go Refix indices on actions table (#20158) 2 years ago
action_list.go Move almost all functions' parameter db.Engine to context.Context (#19748) 2 years ago
action_test.go Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
consistency.go Move issues related files into models/issues (#19931) 2 years ago
error.go Move issues related files into models/issues (#19931) 2 years ago
fixture_generation.go Move access and repo permission to models/perm/access (#19350) 2 years ago
fixture_test.go Decouple unit test code from business code (#17623) 3 years ago
main_test.go Move issues related files into models/issues (#19931) 2 years ago
migrate.go Move issues related files into models/issues (#19931) 2 years ago
migrate_test.go Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
notification.go Add more linters to improve code readability (#19989) 2 years ago
notification_test.go Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
org.go Use neutral language in comments and docs (#20135) 2 years ago
org_team.go Move issues related files into models/issues (#19931) 2 years ago
org_team_test.go Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
org_test.go Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
release.go Add more linters to improve code readability (#19989) 2 years ago
repo.go Add option to purge users (#18064) 2 years ago
repo_activity.go Move issues related files into models/issues (#19931) 2 years ago
repo_collaboration.go Move issues related files into models/issues (#19931) 2 years ago
repo_collaboration_test.go Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
repo_test.go Move tests as seperate sub packages to reduce duplicated file names (#19951) 2 years ago
repo_transfer.go Move issues related files into models/issues (#19931) 2 years ago
repo_transfer_test.go Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago
statistic.go Add more linters to improve code readability (#19989) 2 years ago
task.go Fix typos related to ErrTaskDoesNotExist error (#20118) 2 years ago
token.go Use base32 for 2FA scratch token (#18384) 2 years ago
token_test.go A better go code formatter, and now `make fmt` can run in Windows (#17684) 3 years ago
upload.go Remove NewSession method from db.Engine interface (#17577) 3 years ago
user.go Add badge capabilities to users (#20607) 2 years ago
user_heatmap.go Move organization related structs into sub package (#18518) 2 years ago
user_heatmap_test.go Refactor AssertExistsAndLoadBean to use generics (#20797) 2 years ago