mirror of
https://github.com/go-gitea/gitea
synced 2024-12-24 17:44:27 +00:00
Backport #11131 Signed-off-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
parent
cebef5c871
commit
dca8ef9407
@ -329,8 +329,27 @@ func ServCommand(ctx *macaron.Context) {
|
|||||||
results.RepoID = repo.ID
|
results.RepoID = repo.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally if we're trying to touch the wiki we should init it
|
|
||||||
if results.IsWiki {
|
if results.IsWiki {
|
||||||
|
// Ensure the wiki is enabled before we allow access to it
|
||||||
|
if _, err := repo.GetUnit(models.UnitTypeWiki); err != nil {
|
||||||
|
if models.IsErrUnitTypeNotExist(err) {
|
||||||
|
ctx.JSON(http.StatusForbidden, map[string]interface{}{
|
||||||
|
"results": results,
|
||||||
|
"type": "ErrForbidden",
|
||||||
|
"err": "repository wiki is disabled",
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Error("Failed to get the wiki unit in %-v Error: %v", repo, err)
|
||||||
|
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
|
||||||
|
"results": results,
|
||||||
|
"type": "InternalServerError",
|
||||||
|
"err": fmt.Sprintf("Failed to get the wiki unit in %s/%s Error: %v", ownerName, repoName, err),
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally if we're trying to touch the wiki we should init it
|
||||||
if err = wiki_service.InitWiki(repo); err != nil {
|
if err = wiki_service.InitWiki(repo); err != nil {
|
||||||
log.Error("Failed to initialize the wiki in %-v Error: %v", repo, err)
|
log.Error("Failed to initialize the wiki in %-v Error: %v", repo, err)
|
||||||
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
|
ctx.JSON(http.StatusInternalServerError, map[string]interface{}{
|
||||||
|
@ -313,6 +313,19 @@ func HTTP(ctx *context.Context) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if isWiki {
|
||||||
|
// Ensure the wiki is enabled before we allow access to it
|
||||||
|
if _, err := repo.GetUnit(models.UnitTypeWiki); err != nil {
|
||||||
|
if models.IsErrUnitTypeNotExist(err) {
|
||||||
|
ctx.HandleText(http.StatusForbidden, "repository wiki is disabled")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
log.Error("Failed to get the wiki unit in %-v Error: %v", repo, err)
|
||||||
|
ctx.ServerError("GetUnit(UnitTypeWiki) for "+repo.FullName(), err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
environ = append(environ, models.ProtectedBranchRepoID+fmt.Sprintf("=%d", repo.ID))
|
environ = append(environ, models.ProtectedBranchRepoID+fmt.Sprintf("=%d", repo.ID))
|
||||||
|
|
||||||
w := ctx.Resp
|
w := ctx.Resp
|
||||||
|
Loading…
Reference in New Issue
Block a user