aboutsummaryrefslogtreecommitdiff
path: root/weed
diff options
context:
space:
mode:
authorKonstantin Lebedev <9497591+kmlebedev@users.noreply.github.com>2023-06-13 10:22:46 +0500
committerGitHub <noreply@github.com>2023-06-12 22:22:46 -0700
commit4527ead2956c31f3ffca98e7c5af13a3d5b92f1e (patch)
treed59fc1802fce5d1d56fe5b989f6e036f34099620 /weed
parenta25bca06927a171ba1d8d459e573bc083ca8c1a8 (diff)
downloadseaweedfs-4527ead2956c31f3ffca98e7c5af13a3d5b92f1e.tar.xz
seaweedfs-4527ead2956c31f3ffca98e7c5af13a3d5b92f1e.zip
fix from comment delete volume is empty (#4573)
* fix from coments https://github.com/seaweedfs/seaweedfs/pull/4561 * fix tests --------- Co-authored-by: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.co>
Diffstat (limited to 'weed')
-rw-r--r--weed/storage/store.go6
-rw-r--r--weed/storage/volume.go3
2 files changed, 5 insertions, 4 deletions
diff --git a/weed/storage/store.go b/weed/storage/store.go
index cfc409c39..43d4595bf 100644
--- a/weed/storage/store.go
+++ b/weed/storage/store.go
@@ -509,12 +509,12 @@ func (s *Store) UnmountVolume(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)
}
+ if onlyEmpty && !v.IsEmpty() {
+ return fmt.Errorf("delete volume %d not empty", i)
+ }
message := master_pb.VolumeShortInformationMessage{
Id: uint32(v.Id),
Collection: v.Collection,
diff --git a/weed/storage/volume.go b/weed/storage/volume.go
index 31960451c..066f06604 100644
--- a/weed/storage/volume.go
+++ b/weed/storage/volume.go
@@ -333,5 +333,6 @@ func (v *Volume) IsReadOnly() bool {
return v.noWriteOrDelete || v.noWriteCanDelete || v.location.isDiskSpaceLow
}
func (v *Volume) IsEmpty() bool {
- return v.ContentSize() == 0
+ size, _, _ := v.DataBackend.GetStat()
+ return size <= 8 && v.ContentSize() == 0
}