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
Applications no longer works out whether each app is Peel every time
Țugui Dragoșd19944d2627f
diff --git a/Packages/PeelCore/Sources/PeelCore/Apps/InstalledApp.swift b/Packages/PeelCore/Sources/PeelCore/Apps/InstalledApp.swiftindex 2818c2ae..612971f4 100644--- a/Packages/PeelCore/Sources/PeelCore/Apps/InstalledApp.swift+++ b/Packages/PeelCore/Sources/PeelCore/Apps/InstalledApp.swift@@ -27,6 +27,10 @@ public struct InstalledApp: Sendable, Hashable, Identifiable {public let isUseRecorded: Boolpublic let dateAdded: Date?public let updateFeed: UpdateFeed?+ /// Whether this is Peel, which is removed only from its own Settings, where the helper and the login item+ /// are unregistered first. Also true for the bundle the running code sits inside, such as the Peel that+ /// embeds the `peel` tool, whatever its name or identifier.+ public let isPeelItself: Boolpublic init(url: URL,@@ -66,6 +70,7 @@ public struct InstalledApp: Sendable, Hashable, Identifiable {self.isUseRecorded = isUseRecordedself.dateAdded = dateAddedself.updateFeed = updateFeed+ isPeelItself = Self.isPeel(bundleIdentifier, at: url)}public var id: URL { url }@@ -105,15 +110,13 @@ public struct InstalledApp: Sendable, Hashable, Identifiable {)}- /// Whether this is Peel, which is removed only from its own Settings, where the helper and the login item- /// are unregistered first. Also true for the bundle the running code sits inside, such as the Peel that- /// embeds the `peel` tool, whatever its name or identifier.- public var isPeelItself: Bool {+ private static let runningBundle = PathPattern.comparablePath(of: Bundle.main.bundleURL)++ private static func isPeel(_ bundleIdentifier: String, at url: URL) -> Bool {let own = HelperIdentity.appIdentifier.lowercased()let identifier = bundleIdentifier.lowercased()if identifier == own || identifier.hasPrefix(own + ".") { return true }- let running = PathPattern.comparablePath(of: Bundle.main.bundleURL)- return PathComponents.isPath(running, inside: PathPattern.comparablePath(of: url))+ return PathComponents.isPath(runningBundle, inside: PathPattern.comparablePath(of: url))}/// The name Finder shows, which follows the user's language when the app translates it, and the bundle's filediff --git a/Packages/PeelCore/Tests/PeelCoreTests/InstalledAppTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/InstalledAppTests.swiftnew file mode 100644index 00000000..8187bcce--- /dev/null+++ b/Packages/PeelCore/Tests/PeelCoreTests/InstalledAppTests.swift@@ -0,0 +1,23 @@+import Foundation+@testable import PeelCore+import Testing++struct InstalledAppTests {+ @Test func answersWhetherItIsPeelWithoutWorkingItOutAgain() {+ let app = InstalledApp(url: URL(filePath: "/Applications/Editor.app"), bundleIdentifier: "org.example.editor", name: "Editor")+ var answers = 0++ let took = ContinuousClock().measure {+ for _ in 0..<200_000 where app.isPeelItself { answers += 1 }+ }++ #expect(answers == 0)+ #expect(took < .milliseconds(100))+ }++ @Test func theAppAroundTheRunningCodeIsPeelWhateverItIsCalled() {+ let around = InstalledApp(url: Bundle.main.bundleURL.deletingLastPathComponent(), bundleIdentifier: "org.example.around", name: "Around")++ #expect(around.isPeelItself)+ }+}