aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-08-01 00:57:02 +0800
committerGitHub <noreply@github.com>2022-07-31 18:57:02 +0200
commit589677fafb4b77112b7220a1c6089cec71d6db94 (patch)
tree1580defd542b1fe02e1a2f07e5487e6dea47ada6 /routers
parent2c2f75cb2cf0de6fdeeb931377873dd07ffbe774 (diff)
downloadgitea-589677fafb4b77112b7220a1c6089cec71d6db94.tar.gz
gitea-589677fafb4b77112b7220a1c6089cec71d6db94.zip
Add disable download source configuration (#20548)
Add configuration to enable/disable download source from UI. Co-authored-by: zeripath <art27@cantab.net>
Diffstat (limited to 'routers')
-rw-r--r--routers/web/web.go9
1 files changed, 8 insertions, 1 deletions
diff --git a/routers/web/web.go b/routers/web/web.go
index b4e8666c44..a9f43fb2c4 100644
--- a/routers/web/web.go
+++ b/routers/web/web.go
@@ -290,6 +290,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.
@@ -1106,7 +1113,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)