summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2021-06-06 01:59:27 +0200
committerGitHub <noreply@github.com>2021-06-06 02:59:27 +0300
commitee5e1c4a88f2f075587bfbc39438b6d6b1c3044e (patch)
tree5953d6094edeaa0ff65209ead9cc7a3ad6d753dc /routers
parent683cfe39ef2c03f204eb558ba6ec65c2b18b9433 (diff)
downloadgitea-ee5e1c4a88f2f075587bfbc39438b6d6b1c3044e.tar.gz
gitea-ee5e1c4a88f2f075587bfbc39438b6d6b1c3044e.zip
Rewrite of the LFS server (#15523)
* Restructured code. Moved static checks out of loop. * Restructured batch api. Add support for individual errors. * Let router decide if LFS is enabled. * Renamed methods. * Return correct status from verify handler. * Unified media type check in router. * Changed error code according to spec. * Moved checks into router. * Removed invalid v1 api methods. * Unified methods. * Display better error messages. * Added size parameter. Create meta object on upload. * Use object error on invalid size. * Skip upload if object exists. * Moved methods. * Suppress fields in response. * Changed error on accept. * Added tests. * Use ErrorResponse object. * Test against message property. * Add support for the old invalid lfs client. * Fixed the check because MinIO wraps the error. * Use individual repositories. Co-authored-by: 6543 <6543@obermui.de> Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'routers')
-rw-r--r--routers/routes/web.go21
1 files changed, 14 insertions, 7 deletions
diff --git a/routers/routes/web.go b/routers/routes/web.go
index 6d91eb1b3c..fbc41d547d 100644
--- a/routers/routes/web.go
+++ b/routers/routes/web.go
@@ -286,6 +286,13 @@ func RegisterRoutes(m *web.Route) {
}
}
+ lfsServerEnabled := func(ctx *context.Context) {
+ if !setting.LFS.StartServer {
+ 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.
@@ -1042,21 +1049,21 @@ func RegisterRoutes(m *web.Route) {
m.Group("/{reponame}", func() {
m.Group("/info/lfs", func() {
- m.Post("/objects/batch", lfs.BatchHandler)
- m.Get("/objects/{oid}/{filename}", lfs.ObjectOidHandler)
- m.Any("/objects/{oid}", lfs.ObjectOidHandler)
- m.Post("/objects", lfs.PostHandler)
- m.Post("/verify", lfs.VerifyHandler)
+ m.Post("/objects/batch", lfs.CheckAcceptMediaType, lfs.BatchHandler)
+ m.Put("/objects/{oid}/{size}", lfs.UploadHandler)
+ m.Get("/objects/{oid}/{filename}", lfs.DownloadHandler)
+ m.Get("/objects/{oid}", lfs.DownloadHandler)
+ m.Post("/verify", lfs.CheckAcceptMediaType, lfs.VerifyHandler)
m.Group("/locks", func() {
m.Get("/", lfs.GetListLockHandler)
m.Post("/", lfs.PostLockHandler)
m.Post("/verify", lfs.VerifyLockHandler)
m.Post("/{lid}/unlock", lfs.UnLockHandler)
- })
+ }, lfs.CheckAcceptMediaType)
m.Any("/*", func(ctx *context.Context) {
ctx.NotFound("", nil)
})
- }, ignSignInAndCsrf)
+ }, ignSignInAndCsrf, lfsServerEnabled)
m.Group("", func() {
m.Post("/git-upload-pack", repo.ServiceUploadPack)