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.

Judge a folder reached through the data volume as what it is

Țugui Dragoș2339eb03199b
diff --git a/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swift b/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swift
index f92dbfb4..4a66df07 100644
--- a/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swift
@@ -117,9 +117,12 @@ public struct AppFolders: Sendable {
// A whole disk other than the startup disk, and macOS's own folders, which hold no app of anyone else's.
let names = PathComponents.of(path)
if names.count == 2 && names[0] == "volumes" { return .tooBroad }
- // `/System/Volumes/Data` is every folder of the data volume again, under another name.
- if names.first == "system", PathComponents.of(folded(PathPattern.canonical(folder))).first == "system" {
- return .tooBroad
+ // `/System/Volumes/Data` is every folder of the data volume again, under another name, so such a folder is
+ // judged as what the kernel names it. What keeps that name is macOS's own.
+ if names.first == "system" {
+ let place = PathPattern.canonical(folder)
+ guard PathComponents.of(folded(place)).first != "system" else { return .tooBroad }
+ return refusal(of: place, home: home, isInTheCloud: isInTheCloud)
}
if TrashService.isAtOrInsideATrash(folder, home: home) { return .inATrash }
// Listing a folder a cloud keeps can download what it holds.
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AppFoldersTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AppFoldersTests.swift
index 8ea22e5e..3254f9e3 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/AppFoldersTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/AppFoldersTests.swift
@@ -115,6 +115,11 @@ struct AppFoldersTests {
#expect(reached.isThere)
#expect(AppFolders.refusal(of: reached, home: directory.url) == nil)
#expect(AppFolders.refusal(of: URL(filePath: "/System/Applications"), home: directory.url) == .tooBroad)
+ #expect(AppFolders.refusal(of: URL(filePath: "/System/Volumes/Data/Users"), home: directory.url) == .tooBroad)
+ #expect(
+ AppFolders.refusal(of: URL(filePath: "/System/Volumes/Data/Applications"), home: directory.url)
+ == .alreadyLookedIn
+ )
}
@Test func namesWhatItLeavesOutAndKeepsItUntilItIsTakenOff() throws {