Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.
Swift cache-cleanercleanerclideveloper-toolsdisk-cleanupdisk-spaceduplicate-finderhomebrewliquid-glassmac-cleanermacosmacos-appmacos-golden-gatemacos-tahoemacos-tweaksswiftswiftuiterminal-themesuninstalluninstaller
Ask for the helper on an app's page only for what the page can do with it
Țugui Dragoșbc5ef7445e66
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift b/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swiftindex c7146752..5b82de4a 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift@@ -137,6 +137,11 @@ public struct BulkUninstallation: Sendable {/// What a checkbox can select, by the rule of an app's own page: nothing Peel leaves alone or with something/// excluded inside, nothing that needs the helper while it cannot act, no app macOS keeps, that sits inside/// another package, or that the helper may not move, and nothing of Peel.+ /// How many rows only the helper can move and a person could select once it can act.+ public var rowsWaitingForTheHelper: Int {+ privilegedURLs.intersection(selectable(canUseHelper: true)).count+ }+public func selectable(canUseHelper: Bool) -> Set<URL> {Set(items.filter { item in!item.isExcluded && item.removedElsewhere == nil && !item.isBeyondTheHelper && !item.isInTheTrashdiff --git a/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift b/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swiftindex 546c98ed..c48b69fa 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift@@ -432,6 +432,21 @@ public struct Uninstallation: Sendable {return urls}+ /// What the app's page needs the helper for.+ public enum HelperUse: Sendable, Hashable {+ /// Moving this many rows, each of which a person could select once the helper can act.+ case moving(Int)+ case forgettingAReceipt+ }++ /// Nil on a page from which nothing moves. A receipt's files are rows of their own when they are listed, so+ /// `receipts`, what the page's menu can forget, counts only with no row waiting.+ public func helperUse(receipts: Int) -> HelperUse? {+ guard !isExcluded, removedElsewhere == nil else { return nil }+ let rows = privilegedURLs.intersection(selectable(canUseHelper: true)).count+ return rows > 0 ? .moving(rows) : receipts > 0 ? .forgettingAReceipt : nil+ }+/// The app itself, then the selected leftovers.public func removalOrder(of selection: Set<URL>) -> [URL] {guard !isExcluded, removedElsewhere == nil else { return [] }diff --git a/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swiftindex a824f4cb..4dd6f38f 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift@@ -36,6 +36,35 @@ struct UninstallationTests {)}+ @Test func theHelperIsAskedForOnlyWhatThePageCanDoWithIt() {+ let receiptFile = leftover("org.example.app.bom", requiresPrivileges: true)+ let receiptPlist = leftover("org.example.app.plist", requiresPrivileges: true)+ #expect(uninstallation(leftovers: [receiptFile, receiptPlist]).helperUse(receipts: 1) == .moving(2))+ #expect(uninstallation(leftovers: []).helperUse(receipts: 1) == .forgettingAReceipt)+ #expect(uninstallation(leftovers: []).helperUse(receipts: 0) == nil)++ let held = Leftover(+ url: URL(filePath: "/Users/me/Library/Containers/held"),+ kind: .containers,+ match: LeftoverMatch(+ reason: .bundleIdentifier, confidence: .certain, sharedWith: [], heldBack: .holdsDocuments+ ),+ size: 1_000,+ isMeasured: true,+ requiresPrivileges: true+ )+ #expect(uninstallation(leftovers: [held]).helperUse(receipts: 0) == nil)+ let bulk = BulkUninstallation(uninstallations: [uninstallation(leftovers: [held, receiptFile])])+ #expect(bulk.rowsWaitingForTheHelper == 1)++ let agent = InstalledApp(+ url: URL(filePath: "/Applications/GlobalProtect.app", directoryHint: .isDirectory),+ bundleIdentifier: "com.paloaltonetworks.GlobalProtect.client", name: "GlobalProtect",+ teamIdentifier: "PXPZ95SK77"+ )+ #expect(uninstallation(app: agent, leftovers: [receiptFile]).helperUse(receipts: 1) == nil)+ }+/// A management or security agent goes by its maker's uninstaller, so like Peel itself it is listed and nothing of/// it is selected, counted, moved, or handed to the helper.@Test func leavesAnAgentAndItsFilesToItsMakersUninstaller() {diff --git a/Peel/Model/BulkRemovalPlan.swift b/Peel/Model/BulkRemovalPlan.swiftindex 807d9e6c..68990259 100644--- a/Peel/Model/BulkRemovalPlan.swift+++ b/Peel/Model/BulkRemovalPlan.swift@@ -73,10 +73,7 @@ final class BulkRemovalPlan {var privilegedURLs: Set<URL> { bulk?.privilegedURLs ?? [] }- var requiresHelper: Bool { bulk?.privilegedURLs.isEmpty == false }-- /// How many of the page's items only the helper can move.- var privilegedCount: Int { bulk?.privilegedURLs.count ?? 0 }+ var rowsWaitingForTheHelper: Int { bulk?.rowsWaitingForTheHelper ?? 0 }var unreadableLocations: [SearchLocation] { bulk?.unreadableLocations ?? [] }diff --git a/Peel/Model/RemovalPlan.swift b/Peel/Model/RemovalPlan.swiftindex 22a8a6ff..011fd406 100644--- a/Peel/Model/RemovalPlan.swift+++ b/Peel/Model/RemovalPlan.swift@@ -107,12 +107,7 @@ final class RemovalPlan {var privilegedURLs: Set<URL> { uninstallation?.privilegedURLs ?? [] }- var requiresHelper: Bool {- uninstallation?.privilegedURLs.isEmpty == false- }-- /// How many of the page's items only the helper can move.- var privilegedCount: Int { uninstallation?.privilegedURLs.count ?? 0 }+ var helperUse: Uninstallation.HelperUse? { uninstallation?.helperUse(receipts: packageReceipts.count) }/// What a checkbox can select now.var selectable: Set<URL> { choices.selectable }diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swiftindex 6c2ad33f..b0b31981 100644--- a/Peel/Views/AppDetailView.swift+++ b/Peel/Views/AppDetailView.swift@@ -185,9 +185,11 @@ struct AppDetailView: View {) {}.listRowSeparator(.hidden)}- // A receipt's Forget needs the helper as well.- if plan.requiresHelper || !plan.packageReceipts.isEmpty, !helper.canAct {- HelperRequiredBanner(need: .moving(plan.privilegedCount + plan.packageReceipts.count))+ if !helper.canAct, let use = plan.helperUse {+ switch use {+ case .moving(let rows): HelperRequiredBanner(need: .moving(rows))+ case .forgettingAReceipt: HelperRequiredBanner(need: .forgettingThisReceipt)+ }}Group {diff --git a/Peel/Views/MultipleAppsView.swift b/Peel/Views/MultipleAppsView.swiftindex 96112231..7b730525 100644--- a/Peel/Views/MultipleAppsView.swift+++ b/Peel/Views/MultipleAppsView.swift@@ -34,8 +34,8 @@ struct MultipleAppsView: View {needsFullDiskAccess: plan.bulk?.needsFullDiskAccess == true)}- if plan.requiresHelper, !helper.canAct {- HelperRequiredBanner(need: .moving(plan.privilegedCount))+ if plan.rowsWaitingForTheHelper > 0, !helper.canAct {+ HelperRequiredBanner(need: .moving(plan.rowsWaitingForTheHelper))}// Here, above the lists, so they are seen before Move to Trash however long the lists run.BulkRemovalOptions(plan: plan)