Browse Source

cleanly destroy remote files

pull/1172/head
Chris Lu 5 years ago
parent
commit
35393b4a02
  1. 3
      weed/storage/volume.go
  2. 6
      weed/storage/volume_read_write.go
  3. 8
      weed/storage/volume_tier.go

3
weed/storage/volume.go

@ -225,6 +225,9 @@ func (v *Volume) ToVolumeInformationMessage() *master_pb.VolumeInformationMessag
}
func (v *Volume) RemoteStorageNameKey() (storageName, storageKey string) {
if v.volumeTierInfo == nil {
return
}
if len(v.volumeTierInfo.GetFiles()) == 0 {
return
}

6
weed/storage/volume_read_write.go

@ -46,6 +46,12 @@ func (v *Volume) Destroy() (err error) {
err = fmt.Errorf("volume %d is compacting", v.Id)
return
}
storageName, storageKey := v.RemoteStorageNameKey()
if v.HasRemoteFile() && storageName != "" && storageKey != "" {
if backendStorage, found := backend.BackendStorages[storageName]; found {
backendStorage.DeleteFile(storageKey)
}
}
v.Close()
os.Remove(v.FileName() + ".dat")
os.Remove(v.FileName() + ".idx")

8
weed/storage/volume_tier.go

@ -66,6 +66,14 @@ func (v *Volume) maybeLoadVolumeTierInfo() bool {
return true
}
func (v *Volume) HasRemoteFile() bool {
if v.DataBackend == nil {
return false
}
_, ok := v.DataBackend.(*backend.DiskFile)
return !ok
}
func (v *Volume) LoadRemoteFile() error {
tierFile := v.volumeTierInfo.GetFiles()[0]
backendStorage := backend.BackendStorages[tierFile.BackendName()]

Loading…
Cancel
Save