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
Never call a package placed by its own scripts a receipt only
Țugui Dragoș9810f20e514e
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex f101a1e4..1bba9bef 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -175983,6 +175983,112 @@}}},+ "This package’s scripts put its files in place, so its receipt doesn’t say where they are." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Soubory tohoto balíčku rozmístily jeho skripty, takže záznam o instalaci neuvádí, kde jsou."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Die Skripte dieses Pakets legen seine Dateien ab, daher gibt seine Quittung nicht an, wo sie liegen."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Los scripts de este paquete colocaron sus archivos en su sitio, así que su recibo no indica dónde están."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ce sont les scripts de ce paquet qui mettent ses fichiers en place : son reçu n’indique donc pas où ils se trouvent."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Gli script di questo pacchetto hanno collocato i suoi file, quindi la sua ricevuta non indica dove si trovano."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "このパッケージはスクリプトでファイルを配置したため、レシートにはファイルの場所が記載されていません。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "이 패키지의 스크립트가 파일을 배치했으므로 수신 정보에는 파일이 어디에 있는지 나와 있지 않습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "De scripts van dit pakket hebben de bestanden ervan op hun plek gezet, dus het installatiebewijs vermeldt niet waar ze staan."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Skrypty tego pakietu same rozmieściły jego pliki, więc jego potwierdzenie nie podaje, gdzie się one znajdują."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Os scripts deste pacote colocaram os arquivos dele no lugar, por isso o recibo não diz onde eles estão."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Scripturile acestui pachet i‑au pus fișierele la locul lor, așa că recipisa sa nu spune unde se află acestea."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Файлы этого пакета размещают его собственные скрипты, поэтому в квитанции не указано, где они находятся."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Det här paketets skript har placerat filerna, så kvittot anger inte var de finns."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bu paketin dosyalarını kendi betikleri yerleştirdi, bu yüzden makbuzu bu dosyaların nerede olduğunu belirtmiyor."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Файли цього пакета розмістили його скрипти, тож у його квитанції не вказано, де вони лежать."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "此软件包的文件由其脚本放置到位,因此它的回执没有说明这些文件的位置。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "此套件是由其指令碼將檔案放置到位的,因此它的收據沒有說明這些檔案位於何處。"+ }+ }+ }+ },"This part inside the app is Intel only. It runs through Rosetta, or not at all." : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipt.swift b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipt.swiftindex 447c05c9..72f0a2b2 100644--- a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipt.swift+++ b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipt.swift@@ -45,6 +45,9 @@ public struct PackageReceipt: Sendable, Hashable, Identifiable {/// False when `pkgutil` did not say what the package installed, because it failed or ran out of time./// Nothing can then be said about what is left, and an empty list is not "nothing left".public var isFileListKnown = true+ /// True when the package's scripts put its files in place: it installed into a temporary folder, or listed+ /// nothing. Its receipt then doesn't say where they are, so nothing is judged left or gone from it.+ public var installedThroughItsScripts = falsepublic var id: String { identifier }diff --git a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swiftindex ee1a990e..d273df4a 100644--- a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift+++ b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift@@ -267,6 +267,8 @@ public enum PackageReceipts {let listing = await pkgutil(["--files", identifier])let files = lines(of: listing)+ let throughScripts = listing != nil+ && (files.isEmpty || isTemporary(installLocation: info["install-location"] as? String ?? ""))let found = topLevel(files: files, installLocation: installLocation.path(percentEncoded: false))// An app's own rules reach the rest of its package, as they reach its files on its page.@@ -327,8 +329,9 @@ public enum PackageReceipts {volume: volume,items: items,// Judged from the disk: `items` leaves out what is excluded or protected, even while it is there.- nothingLeftOnDisk: listing != nil && found.onDisk.isEmpty,- isFileListKnown: listing != nil+ nothingLeftOnDisk: listing != nil && !throughScripts && found.onDisk.isEmpty,+ isFileListKnown: listing != nil,+ installedThroughItsScripts: throughScripts),paths: files.map { path(of: $0, in: installLocation).path(percentEncoded: false) })@@ -348,6 +351,14 @@ public enum PackageReceipts {return (info, volume, volume.appending(path: location, directoryHint: .isDirectory))}+ /// Whether a package's install location, relative to its volume, is one of the temporary folders an installer's+ /// scripts move files out of.+ static func isTemporary(installLocation location: String) -> Bool {+ let names = PathComponents.of(location).filter { $0 != "." }+ let place = names.first == "private" ? Array(names.dropFirst()) : names+ return place.first == "tmp" || (place.first == "var" && ["tmp", "folders"].contains(place.dropFirst().first))+ }+private static func path(of file: String, in installLocation: URL) -> URL {installLocation.appending(path: file.hasPrefix("./") ? String(file.dropFirst(2)) : file)}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swiftindex 84499815..91108b57 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift@@ -213,6 +213,42 @@ struct PackageReceiptsTests {#expect(items.sorted() == ["Example.plugin", "Vendor Node/One/vendor-node", "org.example/Driver"])}+ @Test func aPackageWhoseScriptsPlaceItsFilesIsNeverReceiptOnly() async throws {+ let directory = try TemporaryDirectory()+ let volume = PathPattern.canonical(directory.url)+ try directory.file("Applications/Mixer.app/Contents/Info.plist", bytes: 16)+ let locations = ["org.example.mixer": "tmp/MXR", "org.example.mixer.scripts": "", "org.example.gone": "Applications"]+ let listings = [+ "org.example.mixer": "Mixer.app\nMixer.app/Contents\nMixer.app/Contents/Info.plist",+ "org.example.mixer.scripts": "",+ "org.example.gone": "Gone.app\nGone.app/Contents",+ ]+ let pkgutil: PackageReceipts.Pkgutil = { arguments in+ switch arguments.first {+ case "--pkgs-plist":+ return PkgutilAnswer.packages("org.example.gone", "org.example.mixer", "org.example.mixer.scripts")+ case "--pkg-info-plist":+ let info = ["volume": volume.path(percentEncoded: false), "install-location": locations[arguments[1]] ?? ""]+ let data = try? PropertyListSerialization.data(fromPropertyList: info, format: .xml, options: 0)+ return data.flatMap { String(data: $0, encoding: .utf8) }+ case "--files":+ return listings[arguments[1]]+ default:+ return nil+ }+ }+ let environment = SearchEnvironment(homeDirectory: volume.appending(path: "home"), rootDirectory: volume)++ let scan = await PackageReceipts.list(exclusions: .none, pkgutil: pkgutil, environment: environment)+ let receipts = scan.receipts++ let byScripts = receipts.filter { $0.identifier.hasPrefix("org.example.mixer") }+ #expect(byScripts.count == 2)+ #expect(byScripts.allSatisfy { $0.installedThroughItsScripts && !$0.nothingLeftOnDisk })+ let gone = try #require(receipts.first { $0.identifier == "org.example.gone" })+ #expect(gone.nothingLeftOnDisk && !gone.installedThroughItsScripts)+ }+@Test func leavesAnAppToFinderWhenMacOSInstalledItsSystemExtension() async throws {let directory = try TemporaryDirectory()let volume = PathPattern.canonical(directory.url)diff --git a/Peel/Views/Packages/PackageDetailView.swift b/Peel/Views/Packages/PackageDetailView.swiftindex 66314920..b4063d0b 100644--- a/Peel/Views/Packages/PackageDetailView.swift+++ b/Peel/Views/Packages/PackageDetailView.swift@@ -126,6 +126,8 @@ struct PackageDetailView: View {private var emptyListReason: LocalizedStringResource {if !receipt.isFileListKnown {"macOS didn’t say what this package installed, so Peel can’t tell what is left."+ } else if receipt.installedThroughItsScripts {+ "This package’s scripts put its files in place, so its receipt doesn’t say where they are."} else if receipt.nothingLeftOnDisk {"Nothing from this package is left on disk."} else {