Browse Source

avoid no such cpd or cpx file

https://github.com/chrislusf/seaweedfs/issues/2928
pull/2932/head
Konstantin Lebedev 3 years ago
parent
commit
c004d8b907
  1. 15
      weed/storage/volume_vacuum.go

15
weed/storage/volume_vacuum.go

@ -135,11 +135,18 @@ func (v *Volume) CommitCompact() error {
}
}
var e error
if e = os.Rename(v.FileName(".cpd"), v.FileName(".dat")); e != nil {
return fmt.Errorf("rename %s: %v", v.FileName(".cpd"), e)
cpdFile := v.FileName(".cpd")
if _, err := os.Stat(cpdFile); err == nil {
if e = os.Rename(cpdFile, v.FileName(".dat")); e != nil {
return fmt.Errorf("rename %s: %v", v.FileName(".cpd"), e)
}
}
if e = os.Rename(v.FileName(".cpx"), v.FileName(".idx")); e != nil {
return fmt.Errorf("rename %s: %v", v.FileName(".cpx"), e)
cpxFile := v.FileName(".cpx")
if _, err := os.Stat(cpdFile); err == nil {
if e = os.Rename(cpxFile, v.FileName(".idx")); e != nil {
return fmt.Errorf("rename %s: %v", v.FileName(".cpx"), e)
}
}
}

Loading…
Cancel
Save