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

Merge pull request #4608 from ivandeex/pr-chunker-crypt

Ivan Andreevc797494d88ca
diff --git a/backend/chunker/chunker.go b/backend/chunker/chunker.go
index 5bdfa7a4d..a8ee098f3 100644
--- a/backend/chunker/chunker.go
+++ b/backend/chunker/chunker.go
@@ -958,6 +958,8 @@ func (f *Fs) put(ctx context.Context, in io.Reader, src fs.ObjectInfo, remote st
}
info := f.wrapInfo(src, chunkRemote, size)
+ // Refill chunkLimit and let basePut repeatedly call chunkingReader.Read()
+ c.chunkLimit = c.chunkSize
// TODO: handle range/limit options
chunk, errChunk := basePut(ctx, wrapIn, info, options...)
if errChunk != nil {
@@ -1166,10 +1168,14 @@ func (c *chunkingReader) updateHashes() {
func (c *chunkingReader) Read(buf []byte) (bytesRead int, err error) {
if c.chunkLimit <= 0 {
// Chunk complete - switch to next one.
+ // Note #1:
// We might not get here because some remotes (eg. box multi-uploader)
// read the specified size exactly and skip the concluding EOF Read.
// Then a check in the put loop will kick in.
- c.chunkLimit = c.chunkSize
+ // Note #2:
+ // The crypt backend after receiving EOF here will call Read again
+ // and we must insist on returning EOF, so we postpone refilling
+ // chunkLimit to the main loop.
return 0, io.EOF
}
if int64(len(buf)) > c.chunkLimit {
diff --git a/fstest/test_all/config.yaml b/fstest/test_all/config.yaml
index 6d9cd3a63..9581d3b5e 100644
--- a/fstest/test_all/config.yaml
+++ b/fstest/test_all/config.yaml
@@ -71,6 +71,10 @@ backends:
remote: "TestChunkerChunk50bSHA1HashS3:"
fastlist: true
maxfile: 1k
+ - backend: "chunker"
+ remote: "TestChunkerOverCrypt:"
+ fastlist: true
+ maxfile: 6k
- backend: "chunker"
remote: "TestChunkerChunk50bMD5QuickS3:"
fastlist: true