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.

Keep each chosen app's bundle among the apps on several apps' page

Țugui Dragoș4cb8b9ce155c
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift b/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift
index 4edca106..23e32e57 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift
@@ -236,7 +236,9 @@ public struct BulkUninstallation: Sendable {
for uninstallation in uninstallations {
let reference = uninstallation.app.reference
- for leftover in uninstallation.scan.leftovers {
+ // A chosen app's bundle is that app's row, whatever another chosen app's scan says of it.
+ for leftover in uninstallation.scan.leftovers
+ where !chosenBundles.contains(PathPattern.comparablePath(of: leftover.url)) {
add(Item(
url: leftover.url,
size: leftover.size,
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/BulkUninstallationTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/BulkUninstallationTests.swift
index 56e02d3c..f390dd55 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/BulkUninstallationTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/BulkUninstallationTests.swift
@@ -32,6 +32,22 @@ struct BulkUninstallationTests {
)
}
+ @Test func aChosenAppsBundleStaysAnAppWhenAnotherChosenAppListsIt() {
+ let synth = app("org.example.synth", "Synth")
+ let effects = app("org.example.synth-fx", "Synth Effects")
+ let synthsFiles = [leftover("/Applications/Synth Effects.app", size: 10, sharedWith: [effects.reference])]
+ let effectsFiles = [leftover("/Applications/Synth.app", size: 10, sharedWith: [synth.reference])]
+
+ for order in [[synth, effects], [effects, synth]] {
+ let bulk = BulkUninstallation(uninstallations: order.map {
+ uninstallation($0, $0 == synth ? synthsFiles : effectsFiles)
+ })
+
+ #expect(Set(bulk.items.filter(\.isApplication).map(\.url)) == [synth.url, effects.url])
+ #expect(bulk.items.count == 2)
+ }
+ }
+
/// A checkbox can select what a row lets the person choose, 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 or the helper may not move, and nothing of an excluded app or of Peel. Everything Peel suggests