Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Leave an excluded app's receipt alone on Package Receipts too

Țugui Dragoș1dfb9316e792
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index b4ce8b8d..b5619f16 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -178199,6 +178199,113 @@
}
}
},
+ "The app this package installed is excluded in Settings, so Peel leaves its receipt alone too." : {
+ "comment" : "The help tag of the Forget Receipt button on a package's page in Package Receipts, while the app the package installed is excluded in Settings > Exclusions.",
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Aplikace, kterou tento balíček nainstaloval, je vyloučená v Nastavení, takže Peel nechává nedotčený i jeho záznam o instalaci."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Die App, die dieses Paket installiert hat, ist in den Einstellungen ausgeschlossen, daher lässt Peel auch seine Quittung unangetastet."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "La app que instaló este paquete está excluida en Ajustes, así que Peel tampoco toca su recibo."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "L’app que ce paquet a installée est exclue dans les Réglages : Peel laisse donc aussi son reçu en place."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "L’app installata da questo pacchetto è esclusa nelle Impostazioni, quindi Peel non tocca neanche la sua ricevuta."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "このパッケージがインストールしたアプリは“設定”で除外されているため、Peelはこのレシートにも手を付けません。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "이 패키지가 설치한 앱이 설정에서 제외되었으므로 Peel은 이 패키지의 수신 정보도 그대로 둡니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "De app die dit pakket heeft geïnstalleerd, is uitgesloten in Instellingen, dus Peel laat ook het installatiebewijs ervan met rust."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Aplikacja zainstalowana przez ten pakiet jest wykluczona w Ustawieniach, więc Peel nie rusza też jego potwierdzenia."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O app que este pacote instalou está excluído nos Ajustes, então o Peel também não mexe no recibo dele."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Aplicația instalată de acest pachet este exclusă în Configurări, așa că Peel lasă neatinsă și recipisa pachetului."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Приложение, которое установил этот пакет, исключено в Настройках, поэтому Peel не трогает и его квитанцию."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Appen som det här paketet installerade är undantagen i Inställningar, så Peel lämnar även paketets kvitto orört."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Bu paketin yüklediği uygulama Ayarlar’da hariç tutulmuş, bu yüzden Peel paketin makbuzuna da dokunmaz."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Програма, яку інсталював цей пакет, є у винятках у Параметрах, тож Peel не торкається також його квитанції."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "此软件包安装的App已在“设置”中被排除,因此Peel也不会触碰它的回执。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "此套件安裝的App已在「設定」中排除,因此Peel也會將它的收據原地保留。"
+ }
+ }
+ }
+ },
"The app writes all of this again the next time it opens. An app may also keep what it remembers about you here, such as a license key or an account you stayed signed in to, and then those go too." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Packages/PackageActions.swift b/Packages/PeelCore/Sources/PeelCore/Packages/PackageActions.swift
index 350265e7..93f3016d 100644
--- a/Packages/PeelCore/Sources/PeelCore/Packages/PackageActions.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Packages/PackageActions.swift
@@ -47,6 +47,9 @@ public enum PackageActions {
static func forget(_ receipt: PackageReceipt, through service: TrashService) async -> TrashResult {
let files = receiptFiles(of: receipt.identifier, onVolume: receipt.volume)
+ guard !receipt.installedAppIsExcluded else {
+ return TrashResult(failures: files.map { TrashFailure(url: $0, reason: .guarded(.excluded)) })
+ }
guard !files.isEmpty else {
// Named by the file macOS would keep, so the failure says which receipt rather than which disk. With the
// folder there, the receipt was forgotten some other way since Peel read it.
diff --git a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipt.swift b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipt.swift
index 7a1e8218..200244a1 100644
--- a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipt.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipt.swift
@@ -55,6 +55,8 @@ public struct PackageReceipt: Sendable, Hashable, Identifiable {
public var installedThroughItsScripts = false
/// The names of the apps the package put on this Mac that are still where it put them.
public var installedApps: [String] = []
+ /// Whether one of those apps is excluded in Settings, which leaves its receipt alone too.
+ public var installedAppIsExcluded = false
public var id: String { identifier }
diff --git a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift
index f61ce0a4..da4a9b36 100644
--- a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift
@@ -363,7 +363,8 @@ public enum PackageReceipts {
nothingLeftOnDisk: listing != nil && !throughScripts && found.onDisk.isEmpty,
isFileListKnown: listing != nil,
installedThroughItsScripts: throughScripts,
- installedApps: apps.map(\.name).sorted()
+ installedApps: apps.map(\.name).sorted(),
+ installedAppIsExcluded: apps.contains(where: exclusions.excludes)
),
paths: files.map { path(of: $0, in: installLocation).path(percentEncoded: false) },
installLocation: installLocation.path(percentEncoded: false)
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift
index ab84b99c..2391d4c6 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift
@@ -332,6 +332,17 @@ struct PackageReceiptsTests {
#expect(scan.receipts.first { $0.identifier == "org.example.mixer.pkg" }?.installedApps == ["Mixer"])
#expect(scan.receipts.first { $0.identifier == "org.example.gone.pkg" }?.installedApps == [])
+ #expect(scan.receipts.allSatisfy { !$0.installedAppIsExcluded })
+
+ let excluding = Exclusions(bundleIdentifiers: ["org.example.mixer"])
+ let kept = await PackageReceipts.list(exclusions: excluding, pkgutil: pkgutil, environment: environment)
+ let mixer = try #require(kept.receipts.first { $0.identifier == "org.example.mixer.pkg" })
+ #expect(mixer.installedAppIsExcluded)
+ try directory.file("private/var/db/receipts/org.example.mixer.pkg.bom", bytes: 16)
+ try directory.file("private/var/db/receipts/org.example.mixer.pkg.plist", bytes: 16)
+ let forgotten = await PackageActions.forget(mixer, exclusions: excluding)
+ #expect(forgotten.trashed.isEmpty)
+ #expect(forgotten.failures.map(\.reason) == [.guarded(.excluded), .guarded(.excluded)])
}
@Test func leavesAnAppToFinderWhenMacOSInstalledItsSystemExtension() async throws {
diff --git a/Peel/Views/Packages/PackageDetailView.swift b/Peel/Views/Packages/PackageDetailView.swift
index 1bfbdb37..0541632c 100644
--- a/Peel/Views/Packages/PackageDetailView.swift
+++ b/Peel/Views/Packages/PackageDetailView.swift
@@ -80,7 +80,7 @@ struct PackageDetailView: View {
.minimumTarget()
}
.buttonStyle(.borderless)
- .disabled(!helper.canAct || !history.mayMove)
+ .disabled(!helper.canAct || !history.mayMove || receipt.installedAppIsExcluded)
.help(forgetHelp)
}
}
@@ -131,7 +131,10 @@ struct PackageDetailView: View {
}
private var forgetHelp: Text {
- helper.canAct
+ if receipt.installedAppIsExcluded {
+ return Text("The app this package installed is excluded in Settings, so Peel leaves its receipt alone too.")
+ }
+ return helper.canAct
? Text("The receipt goes to the Trash. Files stay where they are.")
: Text(helper.standing.whyItCannotAct(registeredByAnotherCopy: helper.isRegisteredByAnotherCopy))
}
diff --git a/SAFETY.md b/SAFETY.md
index dbc28777..cc25d4bd 100644
--- a/SAFETY.md
+++ b/SAFETY.md
@@ -543,9 +543,9 @@ removal plan and no reset, in the app and in `peel`, and nothing moves it to the
page and whatever its bundle is called, nor a folder that holds it a level or two down. A folder named with its
identifier, such as its caches or its container, is left out of every page and never moved, nor is a folder holding
one a level or two down, nor one with a folder inside that macOS won't let Peel list, since such a folder may be in
-there: that holds even for what only the helper could move, as the helper knows nothing of your exclusions. Its other
-files, such as plug-ins, receipts, or a folder named after the app, are excluded only by their own paths, so to keep
-them, exclude them too.
+there: that holds even for what only the helper could move, as the helper knows nothing of your exclusions. Its installer
+receipt stays too, on its page and on Package Receipts. Its other files, such as plug-ins or a folder named after the
+app, are excluded only by their own paths, so to keep them, exclude them too.
Exclusions reach the Homebrew page too, since Homebrew deletes for good: Peel never runs `brew uninstall` for a package
whose app, or whose own folder, you excluded, nor for one with a folder Peel can't look into for an app you excluded,