Fix three scan-correctness bugs: Trash FDA, duplicate rows, inflated estimate#29
Merged
Conversation
…estimate Root cause shared by two of these: TargetedScanner swallowed permission denials and never de-duplicated overlapping targets. 1. "Trash is empty" on a full Trash. ~/.Trash is TCC-protected; without Full Disk Access the recursive enumerator silently yields nothing and fileExists() still returns true, so the scan looked empty. The scanner now probes each target root with open(O_RDONLY|O_DIRECTORY) and reports EPERM/EACCES via the new ScanOutcome.permissionDenied. TrashBinsView surfaces a "Full Disk Access needed" empty-state (Open Settings / Rescan) instead of a false "Trash is empty." 2. Large & Old Files listed the same file twice. That module scans ~ recursively AND ~/Downloads recursively, so Downloads files were enumerated by both targets. Scan results are now de-duplicated by URL. 3. Cleanup freed less than the estimate (~2 GB estimated, 934 MB freed). Same duplicates: the pre-clean estimate summed each duplicate FileItem, while Clean trashes each URL once (the second copy hits a benign "already gone" skip). selectedSize() now counts each URL once, so the "X will be freed" preview matches reality even when a file appears in multiple categories. Bump 1.5.2 -> 1.5.3.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three user-reported scanning bugs, two sharing a root cause in
TargetedScanner(swallowed permission denials + no de-duplication of overlapping targets).1. "Trash is empty" on a full Trash
~/.Trashis TCC-protected. Without Full Disk Access, the recursiveFileManager.enumeratorsilently yields nothing whilefileExists()still returnstrue— so the scan looked empty even with a full Trash.TargetedScannernow probes each target root withopen(O_RDONLY|O_DIRECTORY)and reportsEPERM/EACCESvia the newScanOutcome.permissionDenied(instead of swallowing it).TrashBinsViewshows a "Full Disk Access needed" empty-state (Open Settings / Rescan / Done) rather than a false "Trash is empty."2. Large & Old Files showed the same file twice
LargeOldFilesModulescans~recursively and~/Downloadsrecursively, so Downloads files were enumerated by both targets and surfaced as duplicate rows. Scan results are now de-duplicated by URL across targets.3. Cleanup freed less than the estimate (≈2 GB estimated → 934 MB freed)
Same duplicates: the pre-clean estimate summed each duplicate
FileItem, while Clean trashes each URL once (the second copy hits a benign "already gone" skip, sofreedBytesis correct).selectedSize()now counts each URL once — the "X will be freed" preview matches what actually gets freed, even when a file appears in multiple categories.Tests (red→green, TDD)
testOverlappingTargetsDeduplicateByURL,testSameTargetListedTwiceDeduplicatestestPermissionDeniedDirectoryIsReported,testReadableEmptyDirectoryIsNotPermissionDenied(chmod-000 reproduces the EACCES denial)testSelectedSizeCountsEachURLOnce,testSelectedSizeSumsDistinctSelectedItemsFull suite: 394 passed, 4 skipped, 0 failures. Version bumped 1.5.2 → 1.5.3 (sync check passes).
🤖 Generated with Claude Code