Skip to content

fix(read): keep ZipIterable::len at the central directory entry count - #1221

Merged
Pr0methean merged 2 commits into
zip-rs:masterfrom
ryanduguid:ryan/iterable-len-after-pass
Oct 30, 2026
Merged

Pr0methean merged 2 commits into
zip-rs:masterfrom
ryanduguid:ryan/iterable-len-after-pass

Conversation

@ryanduguid

@ryanduguid ryanduguid commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

ZipIterable::len() returned files.remaining, which counts down during a pass, so once archive.files() had been iterated, archive.len() reported 0 (or the number of entries not yet visited). Its doc says "Number of entries in the central directory". It now returns the central directory's entry count, the same value ZipIterableFiles starts from and resets to. ZipIterableFiles::len() still reports what is left in the pass.

Evidence

  • Before: the new archive_len_is_unchanged_by_iteration test fails on master: left: 1, right: 2.
  • After: cargo test --test iterable_zip: 15 passed.

Tests pass with default features, --all-features and --no-default-features on stable (rustc 1.93.1, Linux). cargo fmt --check --all is clean, and cargo clippy --all-targets is clean with default and all features.

Risk

Only ZipIterable::len() and is_empty() change, and only after a pass has started. ZipIterable is not in a release yet.

Unverified

  • MSRV and nightly builds, and Windows and macOS runs: left to CI.

  • cargo clippy --all-targets --no-default-features fails on master at src/extra_fields/extra_field.rs:369, which this PR doesn't touch.

  • The PR title must conform to Conventional Commits and start with one of the types specified by the Angular convention.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

ZipIterable::len returned the number of entries left in the current pass, so it fell to 0 after iterating with files() even though the archive still had every entry. Return the declared entry count, as documented.
@Pr0methean
Pr0methean enabled auto-merge October 30, 2026 16:05
@Pr0methean
Pr0methean added this pull request to the merge queue Oct 30, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 30, 2026
@Pr0methean
Pr0methean added this pull request to the merge queue Oct 30, 2026
Merged via the queue into zip-rs:master with commit c98a9ec Oct 30, 2026
135 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants