Skip to content

Commit 406127b

Browse files
committed
Renamed methods.
1 parent c51ac32 commit 406127b

File tree

2 files changed

+19
-30
lines changed

2 files changed

+19
-30
lines changed

routers/routes/web.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,9 +1102,11 @@ func RegisterRoutes(m *web.Route) {
11021102
m.Group("/{reponame}", func() {
11031103
m.Group("/info/lfs", func() {
11041104
m.Post("/objects/batch", lfs.BatchHandler)
1105-
m.Get("/objects/{oid}/{filename}", lfs.ObjectOidHandler)
1106-
m.Any("/objects/{oid}", lfs.ObjectOidHandler)
1107-
m.Post("/objects", lfs.PostHandler)
1105+
m.Get("/objects/{oid}/{filename}", lfs.DownloadHandler)
1106+
m.Get("/objects/{oid}", lfs.DownloadHandler)
1107+
m.Put("/objects/{oid}", lfs.UploadHandler)
1108+
m.Any("/objects/{oid}", lfs.LegacyMetaHandler)
1109+
m.Post("/objects", lfs.LegacyPostHandler)
11081110
m.Post("/verify/{oid}", lfs.VerifyHandler)
11091111
m.Group("/locks", func() {
11101112
m.Get("/", lfs.GetListLockHandler)

services/lfs/server.go

Lines changed: 14 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -49,25 +49,6 @@ func (rc *requestContext) VerifyLink(oid string) string {
4949
return setting.AppURL + path.Join(rc.User, rc.Repo+".git", "info/lfs/verify", oid)
5050
}
5151

52-
// ObjectOidHandler is the main request routing entry point into LFS server functions
53-
func ObjectOidHandler(ctx *context.Context) {
54-
if ctx.Req.Method == "GET" || ctx.Req.Method == "HEAD" {
55-
if isValidAccept(ctx.Req) {
56-
getMetaHandler(ctx)
57-
return
58-
}
59-
60-
getContentHandler(ctx)
61-
return
62-
} else if ctx.Req.Method == "PUT" {
63-
PutHandler(ctx)
64-
return
65-
}
66-
67-
log.Warn("Unhandled LFS method: %s for %s/%s OID[%s]", ctx.Req.Method, ctx.Params("username"), ctx.Params("reponame"), ctx.Params("oid"))
68-
writeStatus(ctx, http.StatusNotFound)
69-
}
70-
7152
func getAuthenticatedRepoAndMeta(ctx *context.Context, rc *requestContext, p lfs_module.Pointer, requireWrite bool) (*models.LFSMetaObject, *models.Repository) {
7253
if !p.IsValid() {
7354
log.Info("Attempt to access invalid LFS OID[%s] in %s/%s", p.Oid, rc.User, rc.Repo)
@@ -97,8 +78,8 @@ func getAuthenticatedRepoAndMeta(ctx *context.Context, rc *requestContext, p lfs
9778
return meta, repository
9879
}
9980

100-
// getContentHandler gets the content from the content store
101-
func getContentHandler(ctx *context.Context) {
81+
// DownloadHandler gets the content from the content store
82+
func DownloadHandler(ctx *context.Context) {
10283
rc, p := unpack(ctx)
10384

10485
meta, _ := getAuthenticatedRepoAndMeta(ctx, rc, p, false)
@@ -174,8 +155,14 @@ func getContentHandler(ctx *context.Context) {
174155
logRequest(ctx.Req, statusCode)
175156
}
176157

177-
// getMetaHandler retrieves metadata about the object
178-
func getMetaHandler(ctx *context.Context) {
158+
// LegacyMetaHandler retrieves metadata about the object
159+
func LegacyMetaHandler(ctx *context.Context) {
160+
if !isValidAccept(ctx.Req) {
161+
log.Info("Attempt to call without accepting the correct media type: %s", lfs_module.MediaType)
162+
writeStatus(ctx, http.StatusBadRequest)
163+
return
164+
}
165+
179166
rc, p := unpack(ctx)
180167

181168
meta, _ := getAuthenticatedRepoAndMeta(ctx, rc, p, false)
@@ -197,8 +184,8 @@ func getMetaHandler(ctx *context.Context) {
197184
logRequest(ctx.Req, http.StatusOK)
198185
}
199186

200-
// PostHandler instructs the client how to upload data
201-
func PostHandler(ctx *context.Context) {
187+
// LegacyPostHandler instructs the client how to upload data
188+
func LegacyPostHandler(ctx *context.Context) {
202189
if !isValidAccept(ctx.Req) {
203190
log.Info("Attempt to POST without accepting the correct media type: %s", lfs_module.MediaType)
204191
writeStatus(ctx, http.StatusBadRequest)
@@ -369,8 +356,8 @@ func BatchHandler(ctx *context.Context) {
369356
logRequest(ctx.Req, http.StatusOK)
370357
}
371358

372-
// PutHandler receives data from the client and puts it into the content store
373-
func PutHandler(ctx *context.Context) {
359+
// UploadHandler receives data from the client and puts it into the content store
360+
func UploadHandler(ctx *context.Context) {
374361
rc, p := unpack(ctx)
375362

376363
meta, repository := getAuthenticatedRepoAndMeta(ctx, rc, p, true)

0 commit comments

Comments
 (0)