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.

Share a home's Fonts and Utilities folders between packages as the startup disk's

Țugui Dragoș62eccb9c705c
diff --git a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift
index fb93d668..46feec0e 100644
--- a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift
@@ -23,8 +23,9 @@ public enum PackageReceipts {
/// The same in a home folder, where a package installed for one account writes, each named from that folder.
static let sharedInTheHome: Set<String> = {
let searched = LibraryFolder.inTheUsersLibrary.map { "/Library/" + $0.rawValue }
+ let alsoInAHome = otherSharedDirectories.filter { $0.hasPrefix("/Library/") || $0.hasPrefix("/Applications") }
let own = ProtectedData.accountFolders.map { "/" + $0 }
- return Set(searched + searched.flatMap(ProtectedObjects.ancestors(of:)) + own + ["/", "/Applications"])
+ return Set(searched + searched.flatMap(ProtectedObjects.ancestors(of:)) + alsoInAHome + own + ["/"])
}()
/// Returns whether `receipt` is the installer receipt of the app whose bundle identifier is `identifier`:
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift
index 71d006fc..e9325c07 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift
@@ -73,6 +73,22 @@ struct PackageReceiptsTests {
#expect(!solo.items.contains { $0.requiresPrivileges })
}
+ @Test func aFolderEveryPackageSharesOnTheStartupDiskIsSharedInAHomeToo() {
+ let home = "/Users/example"
+ let files = [
+ "Library", "Library/Fonts", "Library/Fonts/Solo.otf", "Applications", "Applications/Utilities",
+ "Applications/Utilities/Solo Tool.app",
+ ]
+ let inside = ["\(home)/Library/Fonts": ["Solo.otf"], "\(home)/Applications/Utilities": ["Solo Tool.app"]]
+
+ let found = PackageReceipts.topLevel(
+ files: files, installLocation: home, accountHome: home, home: home, namesInside: { inside[$0] },
+ exists: { _ in true }
+ )
+
+ #expect(found.offered == ["\(home)/Applications/Utilities/Solo Tool.app", "\(home)/Library/Fonts/Solo.otf"])
+ }
+
@Test func aPackageOnTheStartupDiskAndInAnAccountAreTwoReceipts() {
let receipt = { (volume: String) in
PackageReceipt(