aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2021-11-22 22:32:16 +0000
committerGitHub <noreply@github.com>2021-11-22 22:32:16 +0000
commit1dbc58f742febbe58df59d4ce4148d2dbec1a20f (patch)
tree4b73978cdcbdff2e88752d8bbfa21478856d4305 /routers
parentbaed01f24753afb600a2984dcb9bcda0bb8502b6 (diff)
downloadgitea-1dbc58f742febbe58df59d4ce4148d2dbec1a20f.tar.gz
gitea-1dbc58f742febbe58df59d4ce4148d2dbec1a20f.zip
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>
Diffstat (limited to 'routers')
-rw-r--r--routers/private/serv.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/routers/private/serv.go b/routers/private/serv.go
index a7ef980d2d..329d80476a 100644
--- a/routers/private/serv.go
+++ b/routers/private/serv.go
@@ -162,6 +162,14 @@ func ServCommand(ctx *context.PrivateContext) {
return
}
+ if repo.IsBroken() {
+ ctx.JSON(http.StatusInternalServerError, private.ErrServCommand{
+ Results: results,
+ Err: "Repository is in a broken state",
+ })
+ return
+ }
+
// We can shortcut at this point if the repo is a mirror
if mode > models.AccessModeRead && repo.IsMirror {
ctx.JSON(http.StatusForbidden, private.ErrServCommand{