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
Say All users on the disk's receipt of a package also installed for you
Țugui Dragoșfe31c4db14e2
diff --git a/Packages/PeelCore/Sources/PeelCore/Packages/PackageActions.swift b/Packages/PeelCore/Sources/PeelCore/Packages/PackageActions.swiftindex ebcd7bcb..a9e95165 100644--- a/Packages/PeelCore/Sources/PeelCore/Packages/PackageActions.swift+++ b/Packages/PeelCore/Sources/PeelCore/Packages/PackageActions.swift@@ -50,10 +50,10 @@ public enum PackageActions {/// Whether forgetting `receipt` takes Peel's helper: a disk's receipts are root's, and one in a home folder is that/// account's.public static func forgettingNeedsTheHelper(_ receipt: PackageReceipt, home: URL = .homeDirectory) -> Bool {- !isTheHome(receipt.volume, home: home)+ !receipt.isInstalledForTheAccount(home: home)}- private static func isTheHome(_ volume: URL, home: URL) -> Bool {+ static func isTheHome(_ volume: URL, home: URL) -> Bool {PathPattern.comparablePath(of: volume) == PathPattern.comparablePath(of: home)}diff --git a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipt.swift b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipt.swiftindex ed3b36e9..d60d5bd7 100644--- a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipt.swift+++ b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipt.swift@@ -63,6 +63,19 @@ public struct PackageReceipt: Sendable, Hashable, Identifiable {/// `version` is the package's own number.public var productVersion: String?+ /// Whether the package was installed for the account whose home folder is `home` alone, which keeps its receipt+ /// there.+ public func isInstalledForTheAccount(home: URL = .homeDirectory) -> Bool {+ PackageActions.isTheHome(volume, home: home)+ }++ /// The receipts on a disk of the packages also installed for the account, whose rows would otherwise read alike.+ public static func sayingForAllUsers(_ receipts: [PackageReceipt], home: URL = .homeDirectory) -> Set<ID> {+ let forTheAccount = Set(receipts.filter { $0.isInstalledForTheAccount(home: home) }.map(\.identifier))+ return Set(receipts.filter { forTheAccount.contains($0.identifier) && !$0.isInstalledForTheAccount(home: home) }+ .map(\.id))+ }+/// What a list in a question calls each of `receipts`: its name, unless another of them has it too, as the packages/// of one installer do, which is no way to tell them apart.public static func names(of receipts: [PackageReceipt]) -> [String] {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swiftindex e9325c07..6ff749d9 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift@@ -89,6 +89,23 @@ struct PackageReceiptsTests {#expect(found.offered == ["\(home)/Applications/Utilities/Solo Tool.app", "\(home)/Library/Fonts/Solo.otf"])}+ @Test func onlyTheDisksCopyOfAPackageAlsoInstalledForTheAccountSaysAllUsers() {+ let home = URL(filePath: "/Users/example", directoryHint: .isDirectory)+ let disk = URL(filePath: "/", directoryHint: .isDirectory)+ let receipt = { (identifier: String, volume: URL) in+ PackageReceipt(identifier: identifier, version: nil, installDate: nil, volume: volume, items: [])+ }+ let shared = receipt("org.example.solo", disk)++ let marked = PackageReceipt.sayingForAllUsers(+ [shared, receipt("org.example.solo", home), receipt("org.example.other", disk)], home: home+ )++ #expect(marked == [shared.id])+ #expect(receipt("org.example.solo", home).isInstalledForTheAccount(home: home))+ #expect(!shared.isInstalledForTheAccount(home: home))+ }+@Test func aPackageOnTheStartupDiskAndInAnAccountAreTwoReceipts() {let receipt = { (volume: String) inPackageReceipt(diff --git a/Peel/Views/Packages/PackageList.swift b/Peel/Views/Packages/PackageList.swiftindex 96885a0f..ae493e1c 100644--- a/Peel/Views/Packages/PackageList.swift+++ b/Peel/Views/Packages/PackageList.swift@@ -13,11 +13,12 @@ struct PackageList: View {@Bindable var packages = packageslet filtered = filteredReceiptslet receiptsOnly = filtered.filter(\.nothingLeftOnDisk)+ let forAllUsers = PackageReceipt.sayingForAllUsers(packages.receipts ?? [])List(selection: $packages.selection) {if !receiptsOnly.isEmpty {Section {- ForEach(receiptsOnly) { row(for: $0) }+ ForEach(receiptsOnly) { row(for: $0, sayingForAllUsers: forAllUsers.contains($0.id)) }} header: {SectionHeaderLine {heading(@@ -40,7 +41,9 @@ struct PackageList: View {}}Section {- ForEach(filtered.filter { !$0.nothingLeftOnDisk }) { row(for: $0) }+ ForEach(filtered.filter { !$0.nothingLeftOnDisk }) {+ row(for: $0, sayingForAllUsers: forAllUsers.contains($0.id))+ }} header: {if !receiptsOnly.isEmpty {Text("Installed Packages")@@ -108,7 +111,7 @@ struct PackageList: View {return .content}- private func row(for receipt: PackageReceipt) -> some View {+ private func row(for receipt: PackageReceipt, sayingForAllUsers: Bool) -> some View {HStack(spacing: 6) {VStack(alignment: .leading, spacing: 2) {Text(receipt.identifier)@@ -128,6 +131,9 @@ struct PackageList: View {if let version = receipt.shownVersion {Text("Version \(version)")}+ if sayingForAllUsers {+ Text("All users")+ }}.font(.caption).foregroundStyle(.secondary)