Skip to content

Fix prehash cache bypass causing full hash on all files in second scan#1907

Open
darktorres wants to merge 1 commit intoqarmin:masterfrom
darktorres:fix/prehash-cache-bypass
Open

Fix prehash cache bypass causing full hash on all files in second scan#1907
darktorres wants to merge 1 commit intoqarmin:masterfrom
darktorres:fix/prehash-cache-bypass

Conversation

@darktorres
Copy link
Copy Markdown
Contributor

Summary

  • Cached prehash entries were appended to pre_checked_map unconditionally, skipping the len() > 1 collision filter that freshly-computed entries go through. On a second scan where all files are cached, every file was forwarded to full hashing regardless of whether their prehashes actually collided.
  • Also fixed a latent bug where a cached file and a freshly-computed file sharing the same prehash were never detected as a collision, since each loop only checked within its own set.
  • Both loops are now replaced with a single merge-then-filter pass over a combined (size -> hash -> files) map.

Test plan

  • Ran cargo check -p czkawka_core — clean compile
  • Ran existing duplicate tests (cargo test -p czkawka_core -- duplicate) — all pass
  • Validated in the app: second scan no longer full-hashes all files

🤖 Generated with Claude Code

…d scan

Cached prehash entries were appended to pre_checked_map unconditionally,
skipping the collision filter that freshly-computed entries go through.
On a second scan where all files are cached, every file was forwarded to
full hashing regardless of prehash result.

Also fixed a latent bug where a cached file and a freshly-computed file
sharing the same prehash were never detected as a collision, since each
loop only checked within its own set. Both loops are now replaced with a
single merge-then-filter pass over a combined (size -> hash -> files) map.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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