Some code improvements (#14266)

This commit is contained in:
Lunny Xiao 2021-01-07 03:23:57 +08:00 committed by GitHub
parent 8688c2be95
commit 3c96a37162
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 3 deletions

View file

@ -413,9 +413,8 @@ func PutHandler(ctx *context.Context) {
}
contentStore := &ContentStore{ObjectStorage: storage.LFS}
bodyReader := ctx.Req.Body().ReadCloser()
defer bodyReader.Close()
if err := contentStore.Put(meta, bodyReader); err != nil {
defer ctx.Req.Request.Body.Close()
if err := contentStore.Put(meta, ctx.Req.Request.Body); err != nil {
// Put will log the error itself
ctx.Resp.WriteHeader(500)
if err == errSizeMismatch || err == errHashMismatch {