mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Fix closing of meta file if meta encoding failed
This commit is contained in:
parent
a5322c50fc
commit
94f1ac599e
6
block.go
6
block.go
|
@ -138,8 +138,10 @@ func writeMetaFile(dir string, meta *BlockMeta) error {
|
|||
enc := json.NewEncoder(f)
|
||||
enc.SetIndent("", "\t")
|
||||
|
||||
if err := enc.Encode(&blockMeta{Version: 1, BlockMeta: meta}); err != nil {
|
||||
return err
|
||||
var merr MultiError
|
||||
if merr.Add(enc.Encode(&blockMeta{Version: 1, BlockMeta: meta})); merr.Err() != nil {
|
||||
merr.Add(f.Close())
|
||||
return merr
|
||||
}
|
||||
if err := f.Close(); err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in a new issue