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:
parent
94ccc95515
commit
d5d28a7513
3 changed files with 206 additions and 39 deletions
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue