Filter un-cleanable items at module boundary, not just ScanCoordinator (1.5.2)#25
Merged
Conversation
Modules will call this on their results before returning so every consumer (ScanCoordinator AND per-module ViewModels/Views that call `module.scan()` directly) sees a filtered set. The single 1.5.1 wire in ScanCoordinator was a partial fix — it only covered Smart Scan; direct module.scan() calls from SystemJunkViewModel, MailAttachmentsView, TrashBinsView, MalwareView, PrivacyView, LargeOldFilesView, and DuplicatesView still leaked uncleanable items to the UI. Adds one Array-extension test asserting category + autoSelect are preserved across the filter.
Each ScanModule now returns only items the current process could trash. Callers don't need to know about the filter — the contract travels with the result. This is what 1.5.1 was supposed to be: the fix has to live at the module boundary, not at the ScanCoordinator, because seven views/ViewModels call `module.scan()` directly: - SystemJunkViewModel — the path the user reported on - MailAttachmentsView - TrashBinsView - MalwareView - PrivacyView - LargeOldFilesView - DuplicatesView ScanCoordinator (Smart Scan) was the only path that went through the 1.5.1 inline filter, so the per-module Clean flow leaked the exact same 10 un-cleanable items the filter was designed to drop: /Library/Caches/com.apple.*, /private/var/log/com.apple.xpc.launchd/*, /Library/Logs/PaloAltoNetworks/*, and the data-vaulted ~/Library/Caches/com.apple.* set. The three modules that don't produce file results (Optimization, Maintenance, Updater, Uninstaller, SpaceLens, Shredder all return [] from scan()) are untouched.
Patch bump. Same UX outcome as 1.5.1 intended — un-cleanable items disappear from the post-clean error count — but the fix is applied inside each producing module's scan() instead of solely at ScanCoordinator, so it covers every per-module Clean flow.
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.
Why this is needed (the 1.5.1 fix was incomplete)
Real-world test on 1.5.2 produced the exact same 10 errors 1.5.1 was supposed to eliminate. Root cause: the 1.5.1 filter sat in
ScanCoordinator.scanModules, which is only the Smart Scan path. The per-module Clean flows — the ones users actually hit when they open System Junk, Mail Attachments, Trash Bins, Malware, Privacy, Large & Old Files, or Duplicates — all bypass the coordinator and callmodule.scan()directly from their views/view models. Those direct callers got unfiltered results.System Junk is the primary feature, and its viewmodel was the one the user's repro hit.
The fix
Push the filter into the module, so the contract travels with the result:
Mechanically:
Array<ScanResult>.filteringUncleanable()is added inMacCleanKit/CleanFilter.swift, and every producing module'sscan()calls it before returning. ScanCoordinator's inline filter is left in place as belt-and-suspenders — modules now do the work, but a forgetting-prone future module still gets caught for Smart Scan.Files touched
Sources/MacCleanKit/CleanFilter.swift— newArray<ScanResult>.filteringUncleanable()extension..filteringUncleanable()to theirscan()return:SystemJunkModule,MailAttachmentsModule,TrashBinsModule,MalwareModule,PrivacyModule,DuplicatesModule,LargeOldFilesModule[]fromscan()and use sidecar managers).Tests/MacCleanKitTests/CleanFilterTests.swift— one new test asserting the array extension preserves category andautoSelectwhile dropping un-cleanable items.VERSION+MCConstants.appVersion→ 1.5.2.Test plan
swift test— 388 tests, 4 skipped, 0 failuresswift build— clean