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>
This commit is contained in:
committed by
GitHub
parent
a25bca0692
commit
4527ead295
@@ -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,
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user