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.

Let one plug-in hold back only itself in a gone app's group

Țugui Dragoș83c15aef9e18
diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift
index d0088e9a..951b89c4 100644
--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift
@@ -73,7 +73,8 @@ public struct OrphanConfidence: Sendable, Hashable {
if running.contains(where: { isOneApp($0.lowercased(), group.identifier.lowercased(), declared: declared) }) {
return OrphanConfidence(level: .unsure, reasons: [.running])
}
- if group.items.contains(where: { $0.heldBack == .loadedByOtherApps }) {
+ // A plug-in's row says so and isn't recommended, while what else the app left is judged by the signs below.
+ if group.items.allSatisfy({ $0.heldBack == .loadedByOtherApps }) {
return OrphanConfidence(level: .unsure, reasons: [.loadedByOtherApps])
}
// Links into an app that is gone lead nowhere, whatever their dates or the maker's other apps suggest.
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanConfidenceTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanConfidenceTests.swift
index 287d1c0c..bb0fc73f 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanConfidenceTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanConfidenceTests.swift
@@ -34,6 +34,29 @@ struct OrphanConfidenceTests {
)
}
+ @Test func aPlugInOtherAppsLoadHoldsBackItselfAndNotTheRestOfItsGroup() {
+ let app = left("Example", daysAgo: 400)
+ var plugIn = OrphanItem(
+ url: URL(filePath: "/Users/someone/Library/Audio/Plug-Ins/Components/Example.component"),
+ kind: .plugIns, size: 1_000, modificationDate: now.addingTimeInterval(-400 * 24 * 60 * 60),
+ requiresPrivileges: false
+ )
+ plugIn.heldBack = .loadedByOtherApps
+ let settings = OrphanItem(
+ url: URL(filePath: "/Users/someone/Library/Preferences/com.example.app.plist"),
+ kind: .preferences, size: 1_000, modificationDate: now.addingTimeInterval(-401 * 24 * 60 * 60),
+ requiresPrivileges: false
+ )
+ var mixed = OrphanGroup(identifier: "com.example.app", items: [plugIn, settings], rememberedApp: app)
+ let alone = OrphanGroup(identifier: "com.example.app", items: [plugIn], rememberedApp: app)
+
+ mixed.confidence = OrphanConfidence.judge(mixed, now: now)
+
+ #expect(mixed.confidence.level == .certain)
+ #expect(mixed.selectableRows(canUseHelper: true).recommended == [settings.url])
+ #expect(OrphanConfidence.judge(alone, now: now).reasons == [.loadedByOtherApps])
+ }
+
@Test("Something running under that identifier settles it, whatever else is true")
func runningOutranksEverything() {
let old = group(written: 400 * 24 * 60 * 60, remembered: left("Example"))