mirror of
https://github.com/rclone/rclone.git
synced 2025-08-14 15:58:26 +02:00
operations: fix overwrite of destination when multi-thread transfer fails
Before this change, if a multithread upload failed (let's say the source became unavailable) rclone would finalise the file first before aborting the transfer. This caused the partial file to be written which would overwrite any existing files. This was fixed by making sure we Abort the transfer before Close-ing it. This updates the docs to encourage calling of Abort before Close and updates writerAtChunkWriter to make sure that works properly. This also reworks the tests to detect this and to make sure we upload and download to each multi-thread capable backend (we were only downloading before which isn't a full test). Fixes #7071
This commit is contained in:
@ -664,10 +664,12 @@ type ChunkWriter interface {
|
||||
// WriteChunk will write chunk number with reader bytes, where chunk number >= 0
|
||||
WriteChunk(ctx context.Context, chunkNumber int, reader io.ReadSeeker) (bytesWritten int64, err error)
|
||||
|
||||
// Close complete chunked writer
|
||||
// Close complete chunked writer finalising the file.
|
||||
Close(ctx context.Context) error
|
||||
|
||||
// Abort chunk write
|
||||
//
|
||||
// You can and should call Abort without calling Close.
|
||||
Abort(ctx context.Context) error
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user