diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2022-08-12 23:53:10 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-12 23:53:10 +0800 |
commit | eacab6b10dd30a0361f159875571e3e1c42676e1 (patch) | |
tree | 7d19efbb01981b170892d60bbc6ec15d546a415a /routers | |
parent | ac9792c0c771fcc5f629af3a25ff9287f8327d87 (diff) | |
download | gitea-eacab6b10dd30a0361f159875571e3e1c42676e1.tar.gz gitea-eacab6b10dd30a0361f159875571e3e1c42676e1.zip |
Add disable download source configuration (#20548) (#20579)
* Add disable download source configuration (#20548)
Add configuration to enable/disable download source from UI.
Co-authored-by: zeripath <art27@cantab.net>
* Fix BaseVars not used in renderering
* Fix disabled open in vscode menu when disabling download source from UI
Co-authored-by: zeripath <art27@cantab.net>
Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/web.go | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/routers/web/web.go b/routers/web/web.go index d594caf643..b604337715 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -289,6 +289,13 @@ func RegisterRoutes(m *web.Route) { } } + dlSourceEnabled := func(ctx *context.Context) { + if setting.Repository.DisableDownloadSourceArchives { + ctx.Error(http.StatusNotFound) + return + } + } + // FIXME: not all routes need go through same middleware. // Especially some AJAX requests, we can reduce middleware number to improve performance. // Routers. @@ -1096,7 +1103,7 @@ func RegisterRoutes(m *web.Route) { m.Group("/archive", func() { m.Get("/*", repo.Download) m.Post("/*", repo.InitiateDownload) - }, repo.MustBeNotEmpty, reqRepoCodeReader) + }, repo.MustBeNotEmpty, dlSourceEnabled, reqRepoCodeReader) m.Group("/branches", func() { m.Get("", repo.Branches) |