"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files
Go azure-blobazure-blob-storageazure-filesbackblaze-b2cloud-storagedropboxencryptionftpfuse-filesystemgogolanggoogle-cloud-storagegoogle-driveonedriveopenstack-swiftrclones3sftpsyncwebdav
huaweidrive: fix truncated files being uploaded successfully when the source ends early
Rohit Behera83b143103c53
diff --git a/backend/huaweidrive/huaweidrive.go b/backend/huaweidrive/huaweidrive.goindex e9e46367a..4fa1ebdd8 100644--- a/backend/huaweidrive/huaweidrive.go+++ b/backend/huaweidrive/huaweidrive.go@@ -33,6 +33,7 @@ import ("github.com/rclone/rclone/lib/encoder""github.com/rclone/rclone/lib/oauthutil""github.com/rclone/rclone/lib/pacer"+ "github.com/rclone/rclone/lib/readers""github.com/rclone/rclone/lib/rest""golang.org/x/oauth2")@@ -1771,11 +1772,18 @@ func (o *Object) uploadMultipart(ctx context.Context, in io.Reader, leaf, direct}// Read and write file content- _, err = io.Copy(fileWriter, in)+ counter := readers.NewCountingReader(in)+ _, err = io.Copy(fileWriter, counter)if err != nil {return fmt.Errorf("failed to copy file content: %w", err)}+ // Check the source supplied the number of bytes it declared+ // otherwise a truncated file would be stored as a good upload.+ if int64(counter.BytesRead()) != size {+ return fmt.Errorf("expected %d bytes in input, but got %d: %w", size, counter.BytesRead(), io.ErrUnexpectedEOF)+ }+err = writer.Close()if err != nil {return fmt.Errorf("failed to close multipart writer: %w", err)