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

b2: fix streaming chunked files an exact multiple of chunk size

Nick Craig-Wood8f47b6746d0b
diff --git a/backend/b2/upload.go b/backend/b2/upload.go
index ef0102347..777852b1a 100644
--- a/backend/b2/upload.go
+++ b/backend/b2/upload.go
@@ -417,7 +417,13 @@ func (up *largeUpload) Stream(ctx context.Context, initialUploadBlock *pool.RW)
} else {
n, err = io.CopyN(rw, up.in, up.chunkSize)
if err == io.EOF {
- fs.Debugf(up.o, "Read less than a full chunk, making this the last one.")
+ if n == 0 {
+ fs.Debugf(up.o, "Not sending empty chunk after EOF - ending.")
+ up.f.putRW(rw)
+ break
+ } else {
+ fs.Debugf(up.o, "Read less than a full chunk %d, making this the last one.", n)
+ }
hasMoreParts = false
} else if err != nil {
// other kinds of errors indicate failure