Skip to content

Commit c45f43c

Browse files
committed
Use object error on invalid size.
1 parent 24279e1 commit c45f43c

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

services/lfs/server.go

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,8 @@ func BatchHandler(ctx *context.Context) {
199199

200200
rc := getRequestContext(ctx)
201201

202-
repository, err := models.GetRepositoryByOwnerAndName(rc.User, rc.Repo)
203-
if err != nil {
204-
log.Trace("Unable to get repository: %s/%s Error: %v", rc.User, rc.Repo, err)
205-
writeStatus(ctx, http.StatusNotFound)
206-
return
207-
}
208-
209-
if !authenticate(ctx, repository, rc.Authorization, isUpload) {
210-
requireAuth(ctx)
202+
repository := getAuthenticatedRepository(ctx, rc, isUpload)
203+
if repository == nil {
211204
return
212205
}
213206

@@ -248,10 +241,12 @@ func BatchHandler(ctx *context.Context) {
248241

249242
var responseObject *lfs_module.ObjectResponse
250243
if isUpload {
244+
var err *lfs_module.ObjectError
251245
if !exists && setting.LFS.MaxFileSize > 0 && p.Size > setting.LFS.MaxFileSize {
252-
log.Info("Denied LFS OID[%s] upload of size %d to %s/%s because of LFS_MAX_FILE_SIZE=%d", p.Oid, p.Size, rc.User, rc.Repo, setting.LFS.MaxFileSize)
253-
writeStatus(ctx, http.StatusRequestEntityTooLarge)
254-
return
246+
err = &lfs_module.ObjectError{
247+
Code: http.StatusUnprocessableEntity,
248+
Message: fmt.Sprintf("Size must be less than or equal to %d", setting.LFS.MaxFileSize),
249+
}
255250
}
256251

257252
if exists {
@@ -265,7 +260,7 @@ func BatchHandler(ctx *context.Context) {
265260
}
266261
}
267262

268-
responseObject = buildObjectResponse(rc, p, false, !exists, nil)
263+
responseObject = buildObjectResponse(rc, p, false, !exists, err)
269264
} else {
270265
var err *lfs_module.ObjectError
271266
if !exists || meta == nil {

0 commit comments

Comments
 (0)