mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
cleanly destroy remote files
This commit is contained in:
parent
eecad6062a
commit
35393b4a02
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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")
|
||||
|
|
|
@ -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…
Reference in a new issue