Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

operations: fix retries downloading too much data with certain backends

Nick Craig-Wood93955b755fba
diff --git a/fs/operations/reopen.go b/fs/operations/reopen.go
index b2531ced0..9b86c6da3 100644
--- a/fs/operations/reopen.go
+++ b/fs/operations/reopen.go
@@ -138,6 +138,8 @@ func (h *ReOpen) open() error {
// Adjust range start to where we have got to
h.rangeOption.Start = h.start + h.offset
}
+ // Make a copy of the options as fs.FixRangeOption modifies them :-(
+ opts = append(make([]fs.OpenOption, 0, len(opts)), opts...)
h.tries++
if h.tries > h.maxTries {
h.err = errTooManyTries
diff --git a/fs/operations/reopen_test.go b/fs/operations/reopen_test.go
index 153c0334a..891888c50 100644
--- a/fs/operations/reopen_test.go
+++ b/fs/operations/reopen_test.go
@@ -39,6 +39,8 @@ type reOpenTestObject struct {
//
// This will break after reading the number of bytes in breaks
func (o *reOpenTestObject) Open(ctx context.Context, options ...fs.OpenOption) (io.ReadCloser, error) {
+ // Lots of backends do this - make sure it works as it modifies options
+ fs.FixRangeOption(options, o.Size())
gotHash := false
gotRange := false
startPos := int64(0)