aboutsummaryrefslogtreecommitdiff
path: root/weed/storage
diff options
context:
space:
mode:
Diffstat (limited to 'weed/storage')
-rw-r--r--weed/storage/store.go5
-rw-r--r--weed/storage/volume.go3
2 files changed, 7 insertions, 1 deletions
diff --git a/weed/storage/store.go b/weed/storage/store.go
index 40bb7bbe7..cfc409c39 100644
--- a/weed/storage/store.go
+++ b/weed/storage/store.go
@@ -507,8 +507,11 @@ func (s *Store) UnmountVolume(i needle.VolumeId) error {
return fmt.Errorf("volume %d not found on disk", i)
}
-func (s *Store) DeleteVolume(i needle.VolumeId) error {
+func (s *Store) DeleteVolume(i needle.VolumeId, onlyEmpty bool) error {
v := s.findVolume(i)
+ if onlyEmpty && !v.IsEmpty() {
+ return fmt.Errorf("delete volume %d not empty", i)
+ }
if v == nil {
return fmt.Errorf("delete volume %d not found on disk", i)
}
diff --git a/weed/storage/volume.go b/weed/storage/volume.go
index b4cd7b560..31960451c 100644
--- a/weed/storage/volume.go
+++ b/weed/storage/volume.go
@@ -332,3 +332,6 @@ func (v *Volume) IsReadOnly() bool {
defer v.noWriteLock.RUnlock()
return v.noWriteOrDelete || v.noWriteCanDelete || v.location.isDiskSpaceLow
}
+func (v *Volume) IsEmpty() bool {
+ return v.ContentSize() == 0
+}