XL: Close the reader properly.

master
Harshavardhana 9 years ago
parent 7d6ed50fc2
commit 62b4fd6964
  1. 8
      xl-objects-multipart.go

@ -70,8 +70,7 @@ func (m MultipartObjectInfo) GetPartNumberOffset(offset int64) (partIndex int, p
return return
} }
// getMultipartObjectMeta - incomplete meta file and extract meta // getMultipartObjectMeta - incomplete meta file and extract meta information if any.
// information if any.
func getMultipartObjectMeta(storage StorageAPI, metaFile string) (meta map[string]string, err error) { func getMultipartObjectMeta(storage StorageAPI, metaFile string) (meta map[string]string, err error) {
meta = make(map[string]string) meta = make(map[string]string)
offset := int64(0) offset := int64(0)
@ -79,13 +78,14 @@ func getMultipartObjectMeta(storage StorageAPI, metaFile string) (meta map[strin
if err != nil { if err != nil {
return nil, err return nil, err
} }
// Close the metadata reader.
defer objMetaReader.Close()
decoder := json.NewDecoder(objMetaReader) decoder := json.NewDecoder(objMetaReader)
err = decoder.Decode(&meta) err = decoder.Decode(&meta)
if err != nil { if err != nil {
return nil, err return nil, err
} }
// Close the metadata reader.
objMetaReader.Close()
return meta, nil return meta, nil
} }

Loading…
Cancel
Save