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 oversized getfile tail requests

唐僧洗发用飘柔3ca4fd99b6de
diff --git a/fs/operations/rc.go b/fs/operations/rc.go
index 11b229d6f..59501466a 100644
--- a/fs/operations/rc.go
+++ b/fs/operations/rc.go
@@ -1216,6 +1216,9 @@ func rcGetFile(ctx context.Context, in rc.Params) (out rc.Params, err error) {
start := offset
if start < 0 {
start += size
+ if start < 0 {
+ start = 0
+ }
}
if start > size {
start = size
diff --git a/fs/operations/rc_test.go b/fs/operations/rc_test.go
index 038b4f082..802071d5b 100644
--- a/fs/operations/rc_test.go
+++ b/fs/operations/rc_test.go
@@ -979,6 +979,16 @@ func TestRcGetFile(t *testing.T) {
require.NoError(t, err)
assert.Equal(t, "Operation!", out["result"])
+ // A suffix longer than the file represents the whole file.
+ in = rc.Params{
+ "fs": r.FremoteName,
+ "remote": file1.Path,
+ "tail": int64(operations.DefaultGetFileMaxSize + 1),
+ }
+ out, err = call.Fn(ctx, in)
+ require.NoError(t, err)
+ assert.Equal(t, file1Contents, out["result"])
+
// 6. Negative offset
in = rc.Params{
"fs": r.FremoteName,