"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
pikpak: fix truncated single part uploads reported as ok when source ends early
Nick Craig-Wood8e744de5e6c4
diff --git a/backend/pikpak/pikpak.go b/backend/pikpak/pikpak.goindex 59d10d294..df5c3f499 100644--- a/backend/pikpak/pikpak.go+++ b/backend/pikpak/pikpak.go@@ -58,6 +58,7 @@ import ("github.com/rclone/rclone/lib/oauthutil""github.com/rclone/rclone/lib/pacer""github.com/rclone/rclone/lib/random"+ "github.com/rclone/rclone/lib/readers""github.com/rclone/rclone/lib/rest""golang.org/x/oauth2")@@ -1446,10 +1447,11 @@ func (f *Fs) uploadByResumable(ctx context.Context, in io.Reader, name string, sif err != nil {return fmt.Errorf("failed to create upload client: %w", err)}+ counter := readers.NewCountingReader(in)req := &s3.PutObjectInput{Bucket: &p.Bucket,Key: &p.Key,- Body: io.NopCloser(in),+ Body: io.NopCloser(counter),}// Apply upload optionsfor _, option := range options {@@ -1477,7 +1479,14 @@ func (f *Fs) uploadByResumable(ctx context.Context, in io.Reader, name string, s_, err = client.PutObject(ctx, req, s3opts...)return f.shouldRetry(ctx, nil, err)})- return+ if err != nil {+ return err+ }+ // Check for truncation of input+ if size >= 0 && int64(counter.BytesRead()) != size {+ return fmt.Errorf("expected %d bytes in input, but got %d: %w", size, counter.BytesRead(), io.ErrUnexpectedEOF)+ }+ return nil}func (f *Fs) upload(ctx context.Context, in io.Reader, leaf, dirID, gcid string, size int64, options ...fs.OpenOption) (info *api.File, err error) {