mirror of
https://github.com/rclone/rclone.git
synced 2026-06-10 17:34:30 -04:00
The SFTP serve write handler always opened files with O_TRUNC, ignoring the flags requested in the SFTP OPEN packet. Some clients (notably WinSCP's "Process in Background", which resumes an upload on a second connection) re-open the partially written file without the truncate flag and continue writing from the offset they had reached, relying on the existing data being preserved. Forcing O_TRUNC zeroed that prefix, so the start of the uploaded file ended up as a block of zero bytes. This fix respects the requested open flags instead so a resume open without truncate keeps the already written data intact. See: https://forum.rclone.org/t/rclone-serve-sftp-winscp-background-mode-uploading-causes-file-corruption/53841