From 1dbc58f742febbe58df59d4ce4148d2dbec1a20f Mon Sep 17 00:00:00 2001 From: zeripath <art27@cantab.net> Date: Mon, 22 Nov 2021 22:32:16 +0000 Subject: More pleasantly handle broken or missing git repositories (#17747) * More pleasantly handle broken or missing git repositories In #17742 it was noted that there a completely invalid git repository underlying a repo on gitea.com. This happened due to a problem during a migration however, it is not beyond the realms of possibility that a corruption could occur to another user. This PR adds a check to RepoAssignment that will detect if a repository loading has failed due to an absent git repository. It will then show a page suggesting the user contacts the administrator or deletes the repository. Fix #17742 Signed-off-by: Andrew Thornton <art27@cantab.net> * Update options/locale/locale_en-US.ini Co-authored-by: techknowlogick <techknowlogick@gitea.io> Co-authored-by: techknowlogick <techknowlogick@gitea.io> --- models/repo.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'models/repo.go') diff --git a/models/repo.go b/models/repo.go index 7944149a76..860c5c4813 100644 --- a/models/repo.go +++ b/models/repo.go @@ -146,6 +146,7 @@ const ( RepositoryReady RepositoryStatus = iota // a normal repository RepositoryBeingMigrated // repository is migrating RepositoryPendingTransfer // repository pending in ownership transfer state + RepositoryBroken // repository is in a permanently broken state ) // TrustModelType defines the types of trust model for this repository @@ -289,6 +290,11 @@ func (repo *Repository) IsBeingCreated() bool { return repo.IsBeingMigrated() } +// IsBroken indicates that repository is broken +func (repo *Repository) IsBroken() bool { + return repo.Status == RepositoryBroken +} + // AfterLoad is invoked from XORM after setting the values of all fields of this object. func (repo *Repository) AfterLoad() { // FIXME: use models migration to solve all at once. -- cgit v1.2.3