Skip to content

fix(s3): don't leave a partial file when a download fails - #1328

Open
vedant21-oss wants to merge 1 commit into
kitops-ml:mainfrom
vedant21-oss:fix/s3-partial-download
Open

vedant21-oss wants to merge 1 commit into
kitops-ml:mainfrom
vedant21-oss:fix/s3-partial-download

Conversation

@vedant21-oss

Copy link
Copy Markdown
Contributor

Description

DownloadObject wrote s3 datasets straight to the output path, so a failed download left a partial file behind. that file then got skipped as already existing on --ignore-existing, and with --overwrite a failed download wiped the previous good file.

this downloads to <path>.partial first and renames it into place once the copy and close succeed. on any error the partial file is removed and the original file (if any) is left alone. the close error is also checked now instead of being ignored.

i went with a fixed .partial name instead of os.CreateTemp so the file keeps the same permissions as before (CreateTemp makes it 0600).

added TestDownloadObject using the existing mock client: success, failed download with no existing file, and failed download over an existing file. the two failure cases fail on main.

Linked issues

fixes #1327

DownloadObject wrote straight to the output path, so a failed download
left a partial file that --ignore-existing then skipped, and with
--overwrite it replaced the previous file with partial data. Download
to a .partial file and rename it into place once the copy succeeds.

Fixes kitops-ml#1327

Signed-off-by: vedant21-oss <vedantmalodeofficial@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

failed s3 dataset download leaves a partial file behind

1 participant