diff options
author | Allen Wild <aswild@users.noreply.github.com> | 2018-03-27 10:13:20 -0400 |
---|---|---|
committer | Lunny Xiao <xiaolunwen@gmail.com> | 2018-03-27 22:13:20 +0800 |
commit | 15c6bb500b8b395ab7ca61498f5415b9f583213c (patch) | |
tree | 5832b47e529ea73d3421161ed17dcebdb29f721b /routers | |
parent | 321cc2a3d0f267f8b0f5bb4365572636f1ce0443 (diff) | |
download | gitea-15c6bb500b8b395ab7ca61498f5415b9f583213c.tar.gz gitea-15c6bb500b8b395ab7ca61498f5415b9f583213c.zip |
Add repository setting to enable/disable health checks (#3607)
New Feature:
* Repository struct field for IsFsckEnabled (default true of course)
* Admin Settings section on repo options page, accessible only by
admin users
Possible Enhancements:
* There's no way to force running health checks on all repos
regardless of their IsFsckEnabled setting. This would be useful if
there were an admin API or dashboard button to run fsck immediately.
Issue: https://github.com/go-gitea/gitea/issues/1712
Signed-off-by: Allen Wild <allenwild93@gmail.com>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/repo/setting.go | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/routers/repo/setting.go b/routers/repo/setting.go index 6986658b75..0d44cb50a8 100644 --- a/routers/repo/setting.go +++ b/routers/repo/setting.go @@ -229,6 +229,24 @@ func SettingsPost(ctx *context.Context, form auth.RepoSettingForm) { ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success")) ctx.Redirect(ctx.Repo.RepoLink + "/settings") + case "admin": + if !ctx.User.IsAdmin { + ctx.Error(403) + return + } + + if repo.IsFsckEnabled != form.EnableHealthCheck { + repo.IsFsckEnabled = form.EnableHealthCheck + if err := models.UpdateRepository(repo, false); err != nil { + ctx.ServerError("UpdateRepository", err) + return + } + log.Trace("Repository admin settings updated: %s/%s", ctx.Repo.Owner.Name, repo.Name) + } + + ctx.Flash.Success(ctx.Tr("repo.settings.update_settings_success")) + ctx.Redirect(ctx.Repo.RepoLink + "/settings") + case "convert": if !ctx.Repo.IsOwner() { ctx.Error(404) |