@@ -199,15 +199,8 @@ func BatchHandler(ctx *context.Context) {
199
199
200
200
rc := getRequestContext (ctx )
201
201
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 {
211
204
return
212
205
}
213
206
@@ -248,10 +241,12 @@ func BatchHandler(ctx *context.Context) {
248
241
249
242
var responseObject * lfs_module.ObjectResponse
250
243
if isUpload {
244
+ var err * lfs_module.ObjectError
251
245
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
+ }
255
250
}
256
251
257
252
if exists {
@@ -265,7 +260,7 @@ func BatchHandler(ctx *context.Context) {
265
260
}
266
261
}
267
262
268
- responseObject = buildObjectResponse (rc , p , false , ! exists , nil )
263
+ responseObject = buildObjectResponse (rc , p , false , ! exists , err )
269
264
} else {
270
265
var err * lfs_module.ObjectError
271
266
if ! exists || meta == nil {
0 commit comments