Delete volume is empty (#4561)
* use onlyEmpty for deleteVolume https://github.com/seaweedfs/seaweedfs/issues/4559 * fix IsEmpty * fix test --------- Co-authored-by: Konstantin Lebedev <9497591+kmlebedev@users.noreply.github.co>
This commit is contained in:
committed by
GitHub
parent
2e42cdeb22
commit
25535e9c36
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user