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: fix failed uploads leaving disk space in use on the server - fixes #10033

Nick Craig-Woodd545615c1649
diff --git a/backend/sftp/sftp.go b/backend/sftp/sftp.go
index 03c40eaaa..ec520fe2f 100644
--- a/backend/sftp/sftp.go
+++ b/backend/sftp/sftp.go
@@ -2832,6 +2832,8 @@ func (o *Object) Update(ctx context.Context, in io.Reader, src fs.ObjectInfo, op
}
_, err = file.ReadFrom(&sizeReader{Reader: in, size: src.Size()})
if err != nil {
+ // Close the handle otherwise the server keeps the removed file's space allocated
+ _ = file.Close()
o.fs.putSftpConnection(&c, err)
remove()
return fmt.Errorf("Update ReadFrom failed: %w", err)