Skip to content

fix: reject saving a consumed download again - #708

Merged
ffumero2003 merged 1 commit into
masterfrom
fix-py-downloaded-file-double-save
Nov 21, 2026
Merged

ffumero2003 merged 1 commit into
masterfrom
fix-py-downloaded-file-double-save

Conversation

@ffumero2003

Copy link
Copy Markdown
Contributor

Context

Refs #703 (C56 only).

Changes

Track consumption of a DownloadedFile response and reject another save with a clear RuntimeError directing callers to request a new download. Reject save_to() before it opens or truncates a destination. Mark the response consumed when the transfer starts.

Add regression coverage for empty and nonempty streamed responses, destination preservation, and both save entry points. Update the existing C56 audit test to the clear-error contract permitted by #703. Add a bugfix changelog fragment.

Verification

  • Observed RED before implementation: the second save silently succeeded for empty content and raised an opaque StreamConsumedError for nonempty streamed content.
  • Full Python 3.13 unit suites: v3 1,230 passed; v2 1,235 passed; v1 1,299 passed; v0 1,139 passed. All 327 subtests passed; existing skips and expected failures remain.
  • Static tests: 60 passed, 3 expected failures.
  • Ruff lint, changed-file formatting, license checks, towncrier validation, and whitespace checks passed.
  • Whole-tree formatting check flags only unchanged noxfile.py; the same failure was reproduced from master. Left unchanged to keep this PR scoped to C56.
  • Live B2 integration tests were not run.

@ffumero2003 ffumero2003 self-assigned this Nov 21, 2026
@coderabbitai

coderabbitai Bot commented Nov 21, 2026

Copy link
Copy Markdown

Warning

Review limit reached

This organization requires a seat for paid usage-based reviews, including automatic and on-demand reviews. Ask an admin to assign a seat or enable paid usage-based reviews for users without a seat in Billing.

Next included review available in 32 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews 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: fb219052-fdcf-4c31-a66d-3483c7022575
Commits

Reviewing files that changed from the base of the PR and between 08f06b3 and eef9df4.

Files selected for processing: 4

  • b2sdk/_internal/transfer/inbound/downloaded_file.py
  • changelog.d/+downloaded-file-double-save.fixed.md
  • test/unit/bucket/test_bucket.py
  • test/unit/bucket/test_regression_bucket.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

@ffumero2003
ffumero2003 merged commit 6a98314 into master Nov 21, 2026
29 checks passed
@ffumero2003
ffumero2003 deleted the fix-py-downloaded-file-double-save branch November 21, 2026 20:50
ffumero2003 added a commit that referenced this pull request Nov 21, 2026
…#710)

PRs #708 and #709 both edited test/unit/bucket/test_regression_bucket.py;
the clean auto-merge left `defect_raises` imported but unused, failing
ruff (F401) on master. Drop the unused import.
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