Add disable download source configuration (#20548)
Add configuration to enable/disable download source from UI. Co-authored-by: zeripath <art27@cantab.net>
This commit is contained in:
parent
2c2f75cb2c
commit
589677fafb
9 changed files with 39 additions and 16 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue