mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 21:05:10 +00:00
Handle reads with large offsets
This commit is contained in:
parent
a9729eeb1b
commit
5afda94a3c
@ -4,6 +4,7 @@
|
||||
package fuse
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"sync"
|
||||
|
||||
"restic"
|
||||
@ -120,9 +121,16 @@ func (f *file) getBlobAt(i int) (blob []byte, err error) {
|
||||
}
|
||||
|
||||
func (f *file) Read(ctx context.Context, req *fuse.ReadRequest, resp *fuse.ReadResponse) error {
|
||||
debug.Log("file.Read", "Read(%v), file size %v", req.Size, f.node.Size)
|
||||
debug.Log("file.Read", "Read(%v, %v, %v), file size %v", f.node.Name, req.Size, req.Offset, f.node.Size)
|
||||
offset := req.Offset
|
||||
|
||||
lastSize := f.sizes[len(f.sizes)-1]
|
||||
if offset > int64(lastSize) {
|
||||
debug.Log("file.Read", "Read(%v): offset is greater than file size: %v > %v, node size %v",
|
||||
f.node.Name, req.Offset, lastSize, f.node.Size)
|
||||
return errors.New("offset greater than files size")
|
||||
}
|
||||
|
||||
// Skip blobs before the offset
|
||||
startContent := 0
|
||||
for offset > int64(f.sizes[startContent]) {
|
||||
|
Loading…
Reference in New Issue
Block a user