mirror of
https://github.com/rclone/rclone.git
synced 2025-12-06 00:03:32 +00:00
vfs: try to seek buffer on read only files
This commit is contained in:
committed by
Nick Craig-Wood
parent
7d35b14138
commit
552eb8e06b
10
vfs/read.go
10
vfs/read.go
@@ -104,8 +104,16 @@ func (fh *ReadFileHandle) seek(offset int64, reopen bool) (err error) {
|
||||
if fh.noSeek {
|
||||
return ESPIPE
|
||||
}
|
||||
fh.r.StopBuffering() // stop the background reading first
|
||||
fh.hash = nil
|
||||
if !reopen {
|
||||
ar := fh.r.GetAsyncReader()
|
||||
// try to fullfill the seek with buffer discard
|
||||
if ar != nil && ar.SkipBytes(int(offset-fh.offset)) {
|
||||
fh.offset = offset
|
||||
return nil
|
||||
}
|
||||
}
|
||||
fh.r.StopBuffering() // stop the background reading first
|
||||
oldReader := fh.r.GetReader()
|
||||
r, ok := oldReader.(*chunkedreader.ChunkedReader)
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user