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.

Don't offer Uninstall with Peel for an app of the sealed system

Țugui Dragoșeec7a99aab1b
diff --git a/GUIDE.md b/GUIDE.md
index 1ed2fdb6..aa072787 100644
--- a/GUIDE.md
+++ b/GUIDE.md
@@ -51,7 +51,8 @@ and how to get it, [SAFETY.md](SAFETY.md) what it protects, [PRIVACY.md](PRIVACY
Duplicates it has no Select All, since one copy of every group always stays.
- **Several ways in.** Choose an app in the list, drop one on Peel's Dock icon, select several apps at once, or
Control-click an app in Finder and choose Uninstall with Peel, once the Finder extension is on in System
- Settings. With Watch the Trash on, Peel notices when you drag an app to the Trash yourself and offers to clear
+ Settings; an app in macOS's own `/System` folder doesn't offer it, since nothing moves from there. With Watch the
+ Trash on, Peel notices when you drag an app to the Trash yourself and offers to clear
what it left behind, while Peel is open or in the menu bar, and once it has Full Disk Access. An old copy thrown
away while another copy of the app is still installed brings no such offer, since nothing was left behind. Apps
you keep outside the Applications folders, such as on another disk, join the list once you add their folder in
diff --git a/Packages/PeelCore/Sources/PeelLink/OpenRequest.swift b/Packages/PeelCore/Sources/PeelLink/OpenRequest.swift
index e90bb8c3..2ec86eb9 100644
--- a/Packages/PeelCore/Sources/PeelLink/OpenRequest.swift
+++ b/Packages/PeelCore/Sources/PeelLink/OpenRequest.swift
@@ -3,6 +3,10 @@ public import Foundation
public enum OpenRequest {
public static func application(amongSelected items: [URL]) -> URL? {
guard items.count == 1, items[0].pathExtension == "app" else { return nil }
+ // Nothing moves from the sealed system, so the item would only lead to a page saying so. `/System/Volumes`
+ // is where a disk's own data shows, and a person's app may be reached through it.
+ let path = items[0].path(percentEncoded: false)
+ guard !path.hasPrefix("/System/") || path.hasPrefix("/System/Volumes/") else { return nil }
return items[0]
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OpenRequestTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OpenRequestTests.swift
index e3f3c163..607e8bff 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/OpenRequestTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/OpenRequestTests.swift
@@ -67,6 +67,17 @@ struct OpenRequestTests {
#expect(OpenRequest.application(amongSelected: [app, document]) == nil)
}
+ @Test func offersNothingForAnAppOfTheSealedSystem() {
+ func offered(_ path: String) -> Bool {
+ OpenRequest.application(amongSelected: [URL(filePath: path, directoryHint: .isDirectory)]) != nil
+ }
+
+ #expect(!offered("/System/Applications/Calculator.app"))
+ #expect(!offered("/System/Library/CoreServices/Finder.app"))
+ #expect(offered("/System/Volumes/Data/Applications/Foo.app"))
+ #expect(offered("/Applications/Safari.app"))
+ }
+
@Test func theLinkGoesToTheCopyThatHoldsTheExtension() {
let inside = URL(filePath: "/Applications/Peel.app/Contents/PlugIns/PeelFinder.appex")
let alone = URL(filePath: "/Users/x/Build/Products/Debug/PeelFinder.appex")