Use utils.LogClose for deferred closing in miniogw (#239)

This commit is contained in:
Kaloyan Raev 2018-08-17 20:17:58 +03:00 committed by Cameron
parent 906643fce2
commit ae430b8c10

View File

@ -18,6 +18,7 @@ import (
"storj.io/storj/pkg/storage/buckets" "storj.io/storj/pkg/storage/buckets"
"storj.io/storj/pkg/storage/meta" "storj.io/storj/pkg/storage/meta"
"storj.io/storj/pkg/storage/objects" "storj.io/storj/pkg/storage/objects"
"storj.io/storj/pkg/utils"
"storj.io/storj/storage" "storj.io/storj/storage"
) )
@ -111,22 +112,12 @@ func (s *storjObjects) GetObject(ctx context.Context, bucket, object string,
if err != nil { if err != nil {
return err return err
} }
defer func() { defer utils.LogClose(rr)
if err := rr.Close(); err != nil {
// ignore for now
}
}()
r, err := rr.Range(ctx, startOffset, length) r, err := rr.Range(ctx, startOffset, length)
if err != nil { if err != nil {
return err return err
} }
defer utils.LogClose(r)
defer func() {
if err = r.Close(); err != nil {
// ignore for now
}
}()
_, err = io.Copy(writer, r) _, err = io.Copy(writer, r)
return err return err
} }