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.

Decide in one place whether an identifier is Peel's

Țugui Dragoș24b692dc4625
diff --git a/Packages/PeelCore/Sources/PeelCore/Apps/InstalledApp.swift b/Packages/PeelCore/Sources/PeelCore/Apps/InstalledApp.swift
index a8e6af34..3d9ba3b1 100644
--- a/Packages/PeelCore/Sources/PeelCore/Apps/InstalledApp.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Apps/InstalledApp.swift
@@ -163,11 +163,7 @@ public struct InstalledApp: Sendable, Hashable, Identifiable {
private static let runningBundle = PathPattern.comparablePath(of: Bundle.main.bundleURL)
private static func isPeel(_ bundleIdentifier: String?, at path: String) -> Bool {
- let own = HelperIdentity.appIdentifier.lowercased()
- if let identifier = bundleIdentifier?.lowercased(), identifier == own || identifier.hasPrefix(own + ".") {
- return true
- }
- return PathComponents.isPath(runningBundle, inside: path)
+ bundleIdentifier.map(Identifier.isPeels) == true || PathComponents.isPath(runningBundle, inside: path)
}
/// The name Finder shows, which follows the user's language when the app translates it, and the bundle's file
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Naming.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Naming.swift
index e3dfc01a..99b22990 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Naming.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Naming.swift
@@ -1,3 +1,5 @@
+internal import PeelPrivileged
+
enum Naming {
static let separators: Set<Character> = [" ", "-", "_", "."]
@@ -123,6 +125,12 @@ enum Identifier {
}
}
+ /// True for Peel's identifier and those of its parts (`com.tuguidragos.Peel.Helper`), compared without case.
+ static func isPeels(_ identifier: String) -> Bool {
+ let identifier = identifier.lowercased(), own = HelperIdentity.appIdentifier.lowercased()
+ return identifier == own || identifier.hasPrefix(own + ".")
+ }
+
/// True for a group name in one of the forms macOS uses: a team identifier and a dot in front, or `group.`
/// and then a reverse DNS name. Expects the name lowercased, as the matcher keeps its keys.
static func isGroup(_ name: String) -> Bool {
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/PrivacyReset.swift b/Packages/PeelCore/Sources/PeelCore/Removal/PrivacyReset.swift
index 6b332d20..9a541003 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/PrivacyReset.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/PrivacyReset.swift
@@ -93,9 +93,9 @@ public enum PrivacyReset {
/// refused, and any other identifier must read as exactly one app's (`Identifier.isValid`). This matters
/// because `tccutil reset All` with no identifier resets every app.
public static func isAllowed(bundleIdentifier: String) -> Bool {
- let identifier = bundleIdentifier.lowercased()
- let own = HelperIdentity.appIdentifier.lowercased()
- guard !identifier.hasPrefix("com.apple."), identifier != own, !identifier.hasPrefix(own + ".") else { return false }
+ guard !bundleIdentifier.lowercased().hasPrefix("com.apple."), !Identifier.isPeels(bundleIdentifier) else {
+ return false
+ }
return Identifier.isValid(bundleIdentifier)
}
}