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.

Leave a folder others filled to the person in Package Receipts

Țugui Dragoș6f69f35be541
diff --git a/GUIDE.md b/GUIDE.md
index ccef2eea..c0b44e94 100644
--- a/GUIDE.md
+++ b/GUIDE.md
@@ -142,7 +142,8 @@ lists them.
- **Background Items:** launch agents and daemons, and the app that added each one.
- **Extensions:** app extensions and system extensions, and the app each one came with.
- **Plug-ins:** plug-ins of every kind, from audio units to Quick Look.
-- **Package Receipts:** what installer packages put on your Mac, item by item.
+- **Package Receipts:** what installer packages put on your Mac, item by item. A folder a package made that now
+ holds what something else put there is shown and never selected for you.
- **Intel Software:** what still needs Rosetta: apps, the helpers and tools inside universal apps, plug-ins,
drivers, background items, and the commands in `/usr/local`.
- **Homebrew:** your formulae and casks, with Update, Clean Up (and two deeper ones: downloads older than 30 days,
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 0ed9c63e..7a9417af 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -89304,6 +89304,112 @@
}
}
},
+ "Not selected: the package made this folder, but something else put files in it, which may be another program’s or yours." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nevybráno: balíček tuto složku vytvořil, ale něco jiného do ní umístilo soubory, které mohou patřit jinému programu nebo vám."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nicht ausgewählt: Das Paket hat diesen Ordner erstellt, aber etwas anderes hat darin Dateien abgelegt, die möglicherweise einem anderen Programm oder dir gehören."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sin seleccionar: el paquete creó esta carpeta, pero otra cosa ha guardado en ella archivos que pueden ser de otro programa o tuyos."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Non sélectionné : le paquet a créé ce dossier, mais quelque chose d’autre y a placé des fichiers, qui peuvent appartenir à un autre programme ou être les vôtres."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Non selezionato: il pacchetto ha creato questa cartella, ma qualcos’altro ci ha messo dentro dei file, che potrebbero appartenere a un altro programma o a te."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未選択: このフォルダはパッケージが作成したものですが、別の何かが中にファイルを入れており、それらはほかのプログラムのものか、自分のものである可能性があります。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "선택되지 않음: 이 폴더는 패키지가 만들었지만 다른 무언가가 안에 파일을 넣었으며, 그 파일은 다른 프로그램의 것이거나 사용자의 것일 수 있습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Niet geselecteerd: het pakket heeft deze map gemaakt, maar iets anders heeft er bestanden in gezet, die van een ander programma of van jou kunnen zijn."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nie zaznaczono: pakiet utworzył ten folder, ale coś innego umieściło w nim pliki, które mogą należeć do innego programu lub do Ciebie."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Não selecionado: o pacote criou esta pasta, mas outra coisa colocou nela arquivos que podem ser de outro programa ou seus."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Neselectat: pachetul a creat acest dosar, dar altceva a pus în el fișiere, care pot fi ale altui program sau ale dvs."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Не выбрано: эту папку создал пакет, но что-то другое поместило в нее файлы, которые могут принадлежать другой программе или Вам."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Inte markerad: paketet skapade den här mappen, men något annat har lagt filer i den, och de kan tillhöra ett annat program eller dig."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Seçilmedi: paket bu klasörü oluşturdu, ancak içinde başka bir şeyin koyduğu dosyalar var; bunlar başka bir programa veya size ait olabilir."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Не вибрано: цю папку створив пакет, але щось інше поклало в неї файли, які можуть належати іншій програмі або вам."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未选择:该软件包创建了此文件夹,但其中有并非由它放入的文件,这些文件可能属于其他程序,也可能是你自己的。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未選取:這個檔案夾是由此套件產生的,但其中有來自其他來源的檔案,可能屬於其他程式,也可能是你自己的。"
+ }
+ }
+ }
+ },
"Not selected: there is a repository inside, so this folder may hold work that was committed and never pushed anywhere." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
index 45427255..95c67294 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
@@ -314,6 +314,7 @@ extension HoldBack {
case .trackedByGit: "Git tracks files in it"
case .gitTrackingNotKnown: "in a Git repository whose tracked files couldn't be read"
case .sharedWithEveryone: "belongs to everyone on this Mac"
+ case .holdsWhatOthersPut: "holds files something besides this package put there"
case .namedLikeTheApp: "claimed on the app's name alone"
case .holdsAnExclusion: "holds something you excluded"
case .notMeasured: "not measured in time"
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
index d9889474..267fe012 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
@@ -44,6 +44,9 @@ public enum HoldBack: String, Sendable, Hashable {
case gitTrackingNotKnown
/// `/Users/Shared`, which belongs to every account on the Mac rather than to one app.
case sharedWithEveryone
+ /// A folder a package made, offered whole while it holds what something else put there: another package's
+ /// files, or the person's own.
+ case holdsWhatOthersPut
/// Claimed on nothing but the app's name (or an identifier that is only a word), in the home folder or at the
/// top of a Library, where a name alone is only a guess.
case namedLikeTheApp
diff --git a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift
index e7a70043..b9ff0fc6 100644
--- a/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Packages/PackageReceipts.swift
@@ -243,15 +243,18 @@ public enum PackageReceipts {
guard !exclusions.excludes(url), seen.insert(PathPattern.comparablePath(of: url)).inserted else { continue }
let requiresPrivileges = FileAccess.requiresPrivilegesToRemove(url)
let contents = await FileSize.contents(of: url)
- let path = PathPattern.comparablePath(of: url)
- let isShared = shared.contains { PathComponents.isPath(path, atOrInside: $0) }
+ let place = PathPattern.comparablePath(of: url)
+ let isShared = shared.contains { PathComponents.isPath(place, atOrInside: $0) }
+ let isFilledByOthers = found.othersFilled.contains(path)
items.append(PackageReceipt.Item(
url: url,
size: contents.flatMap { $0.couldNotBeRead ? nil : $0.size },
requiresPrivileges: requiresPrivileges,
refusal: removalGuard.refusal(of: url),
heldBack: requiresPrivileges && reach.isBeyond(url)
- ? .beyondTheHelper : HoldBack.seen(in: contents) ?? (isShared ? .sharedWithEveryone : nil)
+ ? .beyondTheHelper
+ : HoldBack.seen(in: contents) ?? (isShared ? .sharedWithEveryone : nil)
+ ?? (isFilledByOthers ? .holdsWhatOthersPut : nil)
))
}
@@ -320,14 +323,15 @@ public enum PackageReceipts {
/// 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.
+ /// 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]? = { try? FileManager.default.contentsOfDirectory(atPath: $0) },
exists: (String) -> Bool = { URL(filePath: $0).isThere }
- ) -> (onDisk: [String], offered: [String]) {
+ ) -> (onDisk: [String], offered: [String], othersFilled: Set<String>) {
let root = (installLocation as NSString).standardizingPath
let paths = files.map { file -> String in
let relative = file.hasPrefix("./") ? String(file.dropFirst(2)) : file
@@ -346,10 +350,13 @@ public enum PackageReceipts {
.filter(exists)
let folded = Set(paths.map { $0.lowercased() })
+ var othersFilled: Set<String> = []
let onDisk = outermost
- .flatMap { onlyWhatThisPackageWrote($0, listed: folded, namesInside: namesInside) }
+ .flatMap {
+ onlyWhatThisPackageWrote($0, listed: folded, namesInside: namesInside, othersFilled: &othersFilled)
+ }
.sorted()
- return (onDisk, onDisk.filter { !ProtectedData.refuses($0, home: home) })
+ return (onDisk, onDisk.filter { !ProtectedData.refuses($0, home: home) }, othersFilled)
}
/// Returns `path` when this package installed everything inside it, and otherwise the parts inside it that
@@ -360,17 +367,25 @@ public enum PackageReceipts {
_ path: String,
listed: Set<String>,
namesInside: (String) -> [String]?,
- depth: Int = 0
+ depth: Int = 0,
+ othersFilled: inout Set<String>
) -> [String] {
- guard (path as NSString).pathExtension.isEmpty, depth < deepestDescent else { return [path] }
+ guard (path as NSString).pathExtension.isEmpty else { return [path] }
guard let names = namesInside(path) else { return [path] }
let inside = names.map { (path as NSString).appendingPathComponent($0) }
guard inside.contains(where: { !listed.contains($0.lowercased()) }) else { return [path] }
let own = inside.filter { listed.contains($0.lowercased()) }
- // Nothing inside is listed: the package installed the folder and something else filled it, so the
- // folder is still the only thing this receipt can name.
- guard !own.isEmpty else { return [path] }
- return own.flatMap { onlyWhatThisPackageWrote($0, listed: listed, namesInside: namesInside, depth: depth + 1) }
+ // Nothing inside is listed, or the search went as deep as it goes: the folder is still the only thing this
+ // receipt can name, and what else is in it is not this package's.
+ guard !own.isEmpty, depth < deepestDescent else {
+ othersFilled.insert(path)
+ return [path]
+ }
+ return own.flatMap {
+ onlyWhatThisPackageWrote(
+ $0, listed: listed, namesInside: namesInside, depth: depth + 1, othersFilled: &othersFilled
+ )
+ }
}
/// A tool that could not be run, or that failed, says nothing about what is installed.
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift
index 7ed4f509..377c713a 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/PackageReceiptsTests.swift
@@ -76,17 +76,18 @@ struct PackageReceiptsTests {
}
/// What may exist nowhere else is left for the person to choose, with its reason: a folder the package made
- /// that now holds a repository or a wallet, and anything in `/Users/Shared`, which every account on the Mac uses.
+ /// that now holds a repository, a wallet, or what something else put there, and anything in `/Users/Shared`.
@Test func leavesToThePersonWhatAReceiptsFolderHolds() async throws {
let directory = try TemporaryDirectory()
let volume = PathPattern.canonical(directory.url)
try directory.file("Library/Application Support/Vendor Repo/.git/HEAD", bytes: 16)
try directory.file("Library/Application Support/Vendor Coin/wallet.dat", bytes: 16)
try directory.file("Library/Application Support/Vendor Plain/data.db", bytes: 16)
+ try directory.file("Library/Application Support/Vendor Shared/Other.component/plugin", bytes: 16)
try directory.file("Users/Shared/StudioSync/project.txt", bytes: 16)
let locations = ["com.example.vendor": "Library/Application Support", "com.example.studio": "Users/Shared"]
let files = [
- "com.example.vendor": "Vendor Repo\nVendor Coin\nVendor Plain\nVendor Plain/data.db\n",
+ "com.example.vendor": "Vendor Repo\nVendor Coin\nVendor Plain\nVendor Plain/data.db\nVendor Shared\n",
"com.example.studio": "StudioSync\n",
]
let pkgutil: PackageReceipts.Pkgutil = { arguments in
@@ -110,6 +111,7 @@ struct PackageReceiptsTests {
let reasons = scan.receipts.flatMap(\.items).map { "\($0.url.lastPathComponent): \($0.heldBack.map(\.rawValue) ?? "none")" }
#expect(reasons.sorted() == [
"StudioSync: sharedWithEveryone", "Vendor Coin: holdsAWallet", "Vendor Plain: none", "Vendor Repo: holdsRepository",
+ "Vendor Shared: holdsWhatOthersPut",
])
}
diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swift
index 87a28b76..4caef319 100644
--- a/Peel/Views/Presentation.swift
+++ b/Peel/Views/Presentation.swift
@@ -255,6 +255,8 @@ extension HoldBack {
"Not selected: this folder is in a Git repository whose list of tracked files Peel couldn’t read, so it may be part of the project."
case .sharedWithEveryone:
"Not selected: /Users/Shared belongs to every account on this Mac rather than to one app."
+ case .holdsWhatOthersPut:
+ "Not selected: the package made this folder, but something else put files in it, which may be another program’s or yours."
case .namedLikeTheApp:
"Not selected: only the name matches, and a folder here may be another program’s, holding work you rely on."
case .holdsAnExclusion:
diff --git a/SAFETY.md b/SAFETY.md
index 718afcfc..7b295d01 100644
--- a/SAFETY.md
+++ b/SAFETY.md
@@ -305,6 +305,8 @@ Never selected for you, even when found:
running, which may install it when the app quits.
- An encrypted disk image, and a disk image, package, or archive outside Downloads that isn't an installed app's
installer, which may be your own rather than something you can download again.
+- A build folder Git tracks files in, and a folder an installer package made that now holds what something else put
+ there, which may be another program's files or yours.
A folder macOS would not let Peel read, and a folder Peel could not measure in time, are not selected either. Both are
shown with their size as "Unknown", never as zero, in every tool and in History once they are moved: a folder too big to