0
0

don't try to close a nil segment if err opening

This commit is contained in:
Marty Schoch 2017-12-14 10:29:19 -05:00
parent 149a26b5c1
commit bd742caf65

View File

@ -212,7 +212,9 @@ func (s *Scorch) persistSnapshot(snapshot *IndexSnapshot) error {
newSegments[segmentID], err = zap.Open(path)
if err != nil {
for _, s := range newSegments {
_ = s.Close() // cleanup segments that were successfully opened
if s != nil {
_ = s.Close() // cleanup segments that were successfully opened
}
}
return fmt.Errorf("error opening new segment at %s, %v", path, err)
}