Skip to content

"rsync for cloud storage" - Google Drive, S3, Dropbox, Backblaze B2, One Drive, Swift, Hubic, Wasabi, Google Cloud Storage, Azure Blob, Azure Files, Yandex Files

sftp: open files for update write only to fix AWS SFTP interop - fixes #3776

Nick Craig-Wooddb39adeb3e13
diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go
index 9d0a1bcbd..ec98c1719 100644
--- a/backend/sftp/sftp.go
+++ b/backend/sftp/sftp.go
@@ -1215,7 +1215,7 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
if err != nil {
return errors.Wrap(err, "Update")
}
- file, err := c.sftpClient.Create(o.path())
+ file, err := c.sftpClient.OpenFile(o.path(), os.O_WRONLY|os.O_CREATE|os.O_TRUNC)
o.fs.putSftpConnection(&c, err)
if err != nil {
return errors.Wrap(err, "Update Create failed")