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

ftp: fix multi-thread copy

WeidiDengd977fa25fa0e
diff --git a/fstest/test_all/config.yaml b/fstest/test_all/config.yaml
index 0e79602aa..cba00b2a6 100644
--- a/fstest/test_all/config.yaml
+++ b/fstest/test_all/config.yaml
@@ -298,10 +298,6 @@ backends:
fastlist: false
- backend: "ftp"
remote: "TestFTPRclone:"
- ignore:
- - "TestMultithreadCopy/{size:131071_streams:2}"
- - "TestMultithreadCopy/{size:131072_streams:2}"
- - "TestMultithreadCopy/{size:131073_streams:2}"
fastlist: false
- backend: "box"
remote: "TestBox:"
diff --git a/lib/readers/limited.go b/lib/readers/limited.go
index 218dd661a..2b346f47e 100644
--- a/lib/readers/limited.go
+++ b/lib/readers/limited.go
@@ -1,6 +1,10 @@
package readers
-import "io"
+import (
+ "io"
+
+ "github.com/rclone/rclone/fs"
+)
// LimitedReadCloser adds io.Closer to io.LimitedReader. Create one with NewLimitedReadCloser
type LimitedReadCloser struct {
@@ -8,6 +12,16 @@ type LimitedReadCloser struct {
io.Closer
}
+// Close closes the underlying io.Closer. The error, if any, will be ignored if data is read completely
+func (lrc *LimitedReadCloser) Close() error {
+ err := lrc.Closer.Close()
+ if err != nil && lrc.N == 0 {
+ fs.Debugf(nil, "ignoring close error because we already got all the data")
+ err = nil
+ }
+ return err
+}
+
// NewLimitedReadCloser returns a LimitedReadCloser wrapping rc to
// limit it to reading limit bytes. If limit < 0 then it does not
// wrap rc, it just returns it.