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
Keep the reset of an excluded app off from the first moment
Țugui Dragoș9f7a7f9dabb2
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift b/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swiftindex bc0cf299..295fee74 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/AppReset.swift@@ -131,6 +131,11 @@ public struct AppReset: Sendable {outcome.stop = .removalsHeld(refusal)return outcome}+ // The reset was prepared before the app may have been excluded.+ if service.excludes(app) {+ outcome.stop = .removalsHeld(.guarded(.excluded))+ return outcome+ }let urls = selected(selection)switch await save(urls) {case .failed:diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGuard.swift b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGuard.swiftindex 80c0eb64..012ce690 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGuard.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGuard.swift@@ -63,6 +63,8 @@ struct RemovalGuard: Sendable {private let syncsToOtherDevices: @Sendable (URL) -> Boolvar knowsTheExclusions: Bool { exclusions.isKnown }++ func excludes(_ app: InstalledApp) -> Bool { exclusions.excludes(app) }private let home: Stringinit(diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swiftindex a031168b..ce7cb80b 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift@@ -335,6 +335,8 @@ public struct TrashService: Sendable {/// False while the saved exclusions are not read yet or cannot be read, when nothing moves.public var knowsTheExclusions: Bool { removalGuard.knowsTheExclusions }+ func excludes(_ app: InstalledApp) -> Bool { removalGuard.excludes(app) }+/// Why every move would be refused now, whatever it is asked to move, or nil when a move may go ahead.public var refusalOfEveryMove: TrashFailure.Reason? {guard knowsTheExclusions else { return .guarded(.exclusionsNotKnown) }diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AppResetTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AppResetTests.swiftindex 149f5b4c..bf694190 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/AppResetTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/AppResetTests.swift@@ -443,6 +443,41 @@ struct AppResetTests {#expect(settings.isThere)}+ @Test func aResetOfAnAppExcludedSinceItsScanTakesNoStep() async throws {+ let directory = try TemporaryDirectory()+ let settings = try directory.file("Library/Preferences/com.example.app.plist", bytes: 4096)+ let reset = await AppReset.prepare(app(), installedApps: [app()], environment: home(directory))+ let trash = try directory.directory("Trash")+ let service = TrashService(+ environment: home(directory),+ exclusions: Exclusions(bundleIdentifiers: ["com.example.app"])+ ) { url in+ let destination = trash.appending(path: url.lastPathComponent)+ try FileManager.default.moveItem(at: url, to: destination)+ return destination+ }+ let steps = Mutex<[String]>([])++ let outcome = await reset.run(+ reset.suggestedSelection,+ resettingPrivacy: true,+ through: service,+ isOpen: { false },+ save: { _ in+ steps.withLock { $0.append("copy") }+ return .nothingToSave+ },+ resetPrivacy: { _ in+ steps.withLock { $0.append("privacy") }+ return .reset+ }+ )++ #expect(outcome.stop == .removalsHeld(.guarded(.excluded)))+ #expect(steps.withLock { $0 }.isEmpty)+ #expect(settings.isThere)+ }+@Test func aResetOffersItsCopyBackOnlyOnceItClearedTheSettings() async throws {let directory = try TemporaryDirectory()let settings = try directory.file("Library/Preferences/com.example.app.plist", bytes: 4096)diff --git a/Peel/Model/RemovalPlan.swift b/Peel/Model/RemovalPlan.swiftindex 48f9514e..1b1b7d7a 100644--- a/Peel/Model/RemovalPlan.swift+++ b/Peel/Model/RemovalPlan.swift@@ -66,8 +66,14 @@ final class RemovalPlan {uninstallation?.appRequiresPrivileges ?? false}+ /// Read from the exclusions, not the scan, so it holds from the first frame and as soon as they change.var isExcluded: Bool {- uninstallation?.isExcluded ?? false+ ExclusionsStore.shared.exclusions.excludes(app)+ }++ var mayResetPrivacy: Bool {+ let exclusions = ExclusionsStore.shared.exclusions+ return exclusions.isKnown && !exclusions.excludes(app)}var isAppBeyondTheHelper: Bool {diff --git a/Peel/Model/ResetPlan.swift b/Peel/Model/ResetPlan.swiftindex eb73131f..2173012b 100644--- a/Peel/Model/ResetPlan.swift+++ b/Peel/Model/ResetPlan.swift@@ -50,8 +50,13 @@ final class ResetPlan {reset?.needsFullDiskAccess ?? false}+ /// Read from the exclusions, not the scan, so an app excluded while the sheet is open shows at once.+ var isExcluded: Bool {+ ExclusionsStore.shared.exclusions.excludes(app)+ }+var canResetPrivacy: Bool {- PrivacyReset.isAllowed(for: app)+ PrivacyReset.isAllowed(for: app) && !isExcluded}var didReset: Bool {@@ -97,7 +102,7 @@ final class ResetPlan {/// Nothing is, until the scan has said what the reset would take: `performReset()` has nothing to go on before.var hasAnythingToReset: Bool {- reset != nil && (!selectedURLs.isEmpty || (resetsPrivacy && canResetPrivacy))+ reset != nil && !isExcluded && (!selectedURLs.isEmpty || (resetsPrivacy && canResetPrivacy))}/// Updates `isAppRunning`. Called when the sheet opens and whenever an app launches or quits.diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swiftindex 7eb7611e..ca99a742 100644--- a/Peel/Views/AppDetailView.swift+++ b/Peel/Views/AppDetailView.swift@@ -42,14 +42,16 @@ struct AppDetailView: View {}.confirmationDialog(Text("Reset privacy permissions for \(plan.app.name)?"), isPresented: $isConfirmingPrivacyReset) {Button("Reset", role: .destructive) {- if let identifier = plan.app.bundleIdentifier {- Task { privacyReset = await PrivacyReset.reset(bundleIdentifier: identifier) }- }+ guard plan.mayResetPrivacy, let identifier = plan.app.bundleIdentifier else { return }+ Task { privacyReset = await PrivacyReset.reset(bundleIdentifier: identifier) }}Button("Cancel", role: .cancel) {}} message: {Text("macOS forgets what \(plan.app.name) was allowed to access, such as the camera, the microphone, or your files, and the app asks you again the next time it needs them. History can’t undo this.")}+ .onChange(of: plan.mayResetPrivacy) { _, may in+ if !may { isConfirmingPrivacyReset = false }+ }.alert(quitTitle, isPresented: Bindable(quitting).isAsking) {Button("Quit \(plan.app.name)") { quitting.quit() }Button("Cancel", role: .cancel) { quitting.giveUp() }diff --git a/Peel/Views/AppPageHeader.swift b/Peel/Views/AppPageHeader.swiftindex 93644819..8e92d448 100644--- a/Peel/Views/AppPageHeader.swift+++ b/Peel/Views/AppPageHeader.swift@@ -116,7 +116,7 @@ struct AppPageHeader: View {if PrivacyReset.isAllowed(for: plan.app), !library.isInATrash(plan.app) {Divider()Button("Reset Privacy Permissions\u{2026}") { isConfirmingPrivacyReset = true }- .disabled(plan.isExcluded)+ .disabled(!plan.mayResetPrivacy)}} label: {Label("More", systemImage: "ellipsis")diff --git a/Peel/Views/ResetSheet.swift b/Peel/Views/ResetSheet.swiftindex 44a3a1f2..12e62e5c 100644--- a/Peel/Views/ResetSheet.swift+++ b/Peel/Views/ResetSheet.swift@@ -182,11 +182,19 @@ struct ResetSheet: View {}.scrollBarBelowSectionHeaders().scanState(phase, scan: plan.scanRun) {- ContentUnavailableView(- "Nothing to Reset",- systemImage: "sparkles",- description: Text("Peel found no settings on this Mac that are certainly \(plan.app.name)’s own.")- )+ if plan.isExcluded {+ ContentUnavailableView(+ "This app is excluded",+ systemImage: "hand.raised",+ description: Text("Peel leaves it and its files alone. Change that in Settings.")+ )+ } else {+ ContentUnavailableView(+ "Nothing to Reset",+ systemImage: "sparkles",+ description: Text("Peel found no settings on this Mac that are certainly \(plan.app.name)’s own.")+ )+ }}.edgeBar(.bottom) { bar }}