aboutsummaryrefslogtreecommitdiff
path: root/weed/storage/volume_read_write.go
diff options
context:
space:
mode:
authorhilimd <68371223+hilimd@users.noreply.github.com>2020-11-05 12:02:47 +0800
committerGitHub <noreply@github.com>2020-11-05 12:02:47 +0800
commit546f1bcb903dd26ba447cdbedb972736fdb31b42 (patch)
tree09b8119faa7162acaa7240de5af6fd0bebe96c2f /weed/storage/volume_read_write.go
parent843865f2ca534bb6286b7a3d79c436384d875608 (diff)
parent75887ba2a20b9f3f7ff9c4b8998cf3af0c0f48c2 (diff)
downloadseaweedfs-546f1bcb903dd26ba447cdbedb972736fdb31b42.tar.xz
seaweedfs-546f1bcb903dd26ba447cdbedb972736fdb31b42.zip
Merge pull request #34 from chrislusf/master
sync
Diffstat (limited to 'weed/storage/volume_read_write.go')
-rw-r--r--weed/storage/volume_read_write.go23
1 files changed, 16 insertions, 7 deletions
diff --git a/weed/storage/volume_read_write.go b/weed/storage/volume_read_write.go
index 94c1d0ea1..869796a3f 100644
--- a/weed/storage/volume_read_write.go
+++ b/weed/storage/volume_read_write.go
@@ -17,6 +17,7 @@ import (
var ErrorNotFound = errors.New("not found")
var ErrorDeleted = errors.New("already deleted")
+var ErrorSizeMismatch = errors.New("size mismatch")
// isFileUnchanged checks whether this needle to write is same as last one.
// It requires serialized access in the same volume.
@@ -55,16 +56,21 @@ func (v *Volume) Destroy() (err error) {
}
}
v.Close()
- os.Remove(v.FileName() + ".dat")
- os.Remove(v.FileName() + ".idx")
- os.Remove(v.FileName() + ".vif")
- os.Remove(v.FileName() + ".sdx")
- os.Remove(v.FileName() + ".cpd")
- os.Remove(v.FileName() + ".cpx")
- os.RemoveAll(v.FileName() + ".ldb")
+ removeVolumeFiles(v.FileName())
return
}
+func removeVolumeFiles(filename string) {
+ os.Remove(filename + ".dat")
+ os.Remove(filename + ".idx")
+ os.Remove(filename + ".vif")
+ os.Remove(filename + ".sdx")
+ os.Remove(filename + ".cpd")
+ os.Remove(filename + ".cpx")
+ os.RemoveAll(filename + ".ldb")
+ os.Remove(filename + ".note")
+}
+
func (v *Volume) asyncRequestAppend(request *needle.AsyncRequest) {
v.asyncRequestsChan <- request
}
@@ -274,6 +280,9 @@ func (v *Volume) readNeedle(n *needle.Needle, readOption *ReadOption) (int, erro
return 0, nil
}
err := n.ReadData(v.DataBackend, nv.Offset.ToAcutalOffset(), readSize, v.Version())
+ if err == needle.ErrorSizeMismatch && OffsetSize == 4 {
+ err = n.ReadData(v.DataBackend, nv.Offset.ToAcutalOffset()+int64(MaxPossibleVolumeSize), readSize, v.Version())
+ }
if err != nil {
return 0, err
}