Skip to content

Restore file position when hashing a stream fails - #230

Open
Lushiyao5 wants to merge 1 commit into
fabiocaccamo:mainfrom
Lushiyao5:fix/hash-stream-position-20261129
Open

Lushiyao5 wants to merge 1 commit into
fabiocaccamo:mainfrom
Lushiyao5:fix/hash-stream-position-20261129

Conversation

@Lushiyao5

Copy link
Copy Markdown
Contributor

get_file_hash restores a caller-owned seekable stream to its original position on success. If reading fails after the initial rewind, it raises the read error but leaves the stream at the wrong position. Restore the original offset in a finally block so callers can recover without losing their place.

The new test checks that the read error propagates and the offset is restored. It fails on the base branch. The file information suite gives 21 passed and 1 skipped on Windows with Python 3.12.

Prepared with assistance from OpenAI Codex.

@codecov

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.59%. Comparing base (5c88544) to head (172640e).
⚠️ Report is 17 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #230      +/-   ##
==========================================
+ Coverage   98.52%   98.59%   +0.07%     
==========================================
  Files          13       13              
  Lines         812      856      +44     
==========================================
+ Hits          800      844      +44     
  Misses         12       12              
Flag Coverage Δ
unittests 98.59% <100.00%> (+0.07%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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