don't try to close a nil segment if err opening
This commit is contained in:
parent
149a26b5c1
commit
bd742caf65
|
@ -212,8 +212,10 @@ func (s *Scorch) persistSnapshot(snapshot *IndexSnapshot) error {
|
||||||
newSegments[segmentID], err = zap.Open(path)
|
newSegments[segmentID], err = zap.Open(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
for _, s := range newSegments {
|
for _, s := range newSegments {
|
||||||
|
if s != nil {
|
||||||
_ = s.Close() // cleanup segments that were successfully opened
|
_ = s.Close() // cleanup segments that were successfully opened
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return fmt.Errorf("error opening new segment at %s, %v", path, err)
|
return fmt.Errorf("error opening new segment at %s, %v", path, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user