Skip to content

fix: preserve existing files when downloads fail - #123

Open
Aakarsh2007 wants to merge 1 commit into
dbpedia:mainfrom
Aakarsh2007:fix/preserve-download-on-interruption
Open

Aakarsh2007 wants to merge 1 commit into
dbpedia:mainfrom
Aakarsh2007:fix/preserve-download-on-interruption

Conversation

@Aakarsh2007

Copy link
Copy Markdown

Description

I reproduced an interrupted download replacing an existing complete file with the first chunk of the new response. A size mismatch also leaves a truncated file, and a checksum mismatch can remove the previous download.

Stage the response on the destination filesystem. Replace the destination atomically only after the stream completes and the existing size and optional checksum checks pass. Temporary files are cleaned up on failure. The change covers standard downloads before any conversion.

Related issues

Related to #93 and #94. This patch protects the destination during a failed full download. It does not add resume support.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • Code follows the project's Ruff rules.
  • Self-reviewed the patch.
  • Added a comment explaining why staging uses the destination filesystem.
  • Updated the changelog and bumped the patch version as directed by the contributing guide.
  • Added regression tests for interrupted streams, size mismatches, checksum mismatches, and successful replacement.
  • Ran the full pytest suite locally, with 285 passed and 3 existing skips. No tests were deselected.
  • Ran ruff check . successfully.

Five regression cases failed on upstream before the fix. All seven new cases passed afterward.

@coderabbitai

coderabbitai Bot commented Dec 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 44 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 92353a6c-a6d7-4bd0-8fe6-cd54b77f91f3
Commits

Reviewing files that changed from the base of the PR and between b35bd2c and bc77850.

Files selected for processing: 4

  • CHANGELOG.md
  • databusclient/api/download.py
  • pyproject.toml
  • tests/test_download_atomic_write.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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.

1 participant