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
Don't read a package's place as gone when the account can't reach it
Țugui Dragoș51536ee84e81
diff --git a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swiftindex e9c3f737..9360bd71 100644--- a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift+++ b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift@@ -440,15 +440,15 @@ public enum PackageReceipts {private static let deepestDescent = 6/// Returns the outermost existing paths that are this package's own, never a shared directory such as- /// `/Library`. `onDisk` holds all of them. `offered` leaves out protected data (`ProtectedData.refuses`),- /// which Peel never lists at all. `othersFilled` holds the folders offered whole that hold what something- /// besides this package put there.+ /// `/Library`. `onDisk` holds all of them, and a path this account can't reach is not gone. `offered` leaves out+ /// protected data (`ProtectedData.refuses`), which Peel never lists at all. `othersFilled` holds the folders+ /// offered whole that hold what something besides this package put there.static func topLevel(files: [String],installLocation: String,home: String = URL.homeDirectory.path(percentEncoded: false),namesInside: (String) -> [String]? = PackageReceipts.namesInside,- exists: (String) -> Bool = { URL(filePath: $0).isThere }+ exists: (String) -> Bool = { !URL(filePath: $0).isMissing }) -> (onDisk: [String], offered: [String], othersFilled: Set<String>) {let root = (installLocation as NSString).standardizingPathlet paths = files.map { file -> String indiff --git a/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swiftindex 8c1d92c3..d20d3303 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift@@ -517,6 +517,44 @@ struct PackageReceiptsTests {#expect(scan.receipts.first?.installedApps == [])}+ @Test(.permissionsHold) func whatTheAccountCannotReachIsNotGone() async throws {+ let directory = try TemporaryDirectory()+ let volume = PathPattern.canonical(directory.url)+ let closed = try directory.directory("Vendor")+ try directory.file("Vendor/Plugins/x", bytes: 16)+ try directory.setPermissions(0o000, of: closed)+ defer { try? directory.setPermissions(0o755, of: closed) }+ let location = closed.path(percentEncoded: false)++ let found = PackageReceipts.topLevel(files: ["Plugins", "Plugins/x"], installLocation: location)+ #expect(!found.onDisk.isEmpty)++ let pkgutil: PackageReceipts.Pkgutil = { arguments in+ switch arguments.first {+ case "--pkgs-plist":+ return PkgutilAnswer.packages("org.example.vendor.pkg")+ case "--pkg-info-plist":+ let info = ["volume": volume.path(percentEncoded: false), "install-location": "Vendor"]+ let data = try? PropertyListSerialization.data(fromPropertyList: info, format: .xml, options: 0)+ return data.flatMap { String(data: $0, encoding: .utf8) }+ case "--files":+ return "Plugins\nPlugins/x\n"+ default:+ return nil+ }+ }+ let environment = SearchEnvironment(homeDirectory: volume.appending(path: "home"), rootDirectory: volume)++ let scan = await PackageReceipts.list(+ exclusions: .none, pkgutil: pkgutil, environment: environment, systemExtensions: { [] }+ )++ let receipt = try #require(scan.receipts.first)+ #expect(!receipt.nothingLeftOnDisk)+ #expect(receipt.items.map(\.size) == [nil])+ #expect(receipt.selectableRows(canUseHelper: true).recommended.isEmpty)+ }+@Test func leavesTheRestOfAPackageToWhatRemovesItsApp() async throws {let directory = try TemporaryDirectory()let volume = PathPattern.canonical(directory.url)