diff --git a/weed/storage/disk_location.go b/weed/storage/disk_location.go index 359d0cec2..9f4ce9de1 100644 --- a/weed/storage/disk_location.go +++ b/weed/storage/disk_location.go @@ -112,10 +112,11 @@ func (l *DiskLocation) loadExistingVolume(fileInfo os.FileInfo, needleMapKind Ne // load the volume v, e := NewVolume(l.Directory, l.IdxDirectory, collection, vid, needleMapKind, nil, nil, 0, 0) if e != nil { + _ = l.DeleteVolume(vid) glog.V(0).Infof("new volume %s error %s", volumeName, e) return false } - + l.SetVolume(vid, v) size, _, _ := v.FileStat() @@ -207,16 +208,15 @@ func (l *DiskLocation) DeleteCollectionFromDiskLocation(collection string) (e er } func (l *DiskLocation) deleteVolumeById(vid needle.VolumeId) (found bool, e error) { - v, ok := l.volumes[vid] - if !ok { - return - } - e = v.Destroy() - if e != nil { - return + v, found := l.volumes[vid] + if found { + if v != nil { + if e = v.Destroy(); e != nil { + return + } + } + delete(l.volumes, vid) } - found = true - delete(l.volumes, vid) return }