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.

Never offer another installed app's folder when uninstalling an app

Țugui Dragoșfbd5f18005a7
diff --git a/GUIDE.md b/GUIDE.md
index cbdd5ad7..26f7ea41 100644
--- a/GUIDE.md
+++ b/GUIDE.md
@@ -21,9 +21,10 @@ and how to get it, [SAFETY.md](SAFETY.md) what it protects, [PRIVACY.md](PRIVACY
database, or a repository is shown with its reason and not selected, and so is a place where an app keeps what
may exist only on this Mac, such as local mail, message history, sign-in codes, VPN connections, a game's saves, a
database, or an app's own backups. Uninstalling Xcode lists the simulators it made the same way.
-- **Shared or guessed, never selected.** A file another installed app also uses is shown but never selected. What
- Peel only guesses at, from the start of a name or an identifier the app's maker or signing team also uses, waits
- under Review Before Removing.
+- **Shared or guessed, never selected.** A file another installed app also uses is shown but never selected, and a
+ folder holding another installed app's own data, such as Xcode's in `~/Library/Developer`, can't be selected at
+ all. What Peel only guesses at, from the start of a name or an identifier the app's maker or signing team also
+ uses, waits under Review Before Removing.
- **The Select menu** has Select Recommended, Select All, and Deselect All. Select All selects everything you can
select, what Peel holds back included, and asks first when that takes anything Peel doesn't recommend.
- **Several ways in.** Choose an app in the list, drop one on Peel's Dock icon, select several apps at once, or
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 73aa01c9..8c758348 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -66983,6 +66983,112 @@
}
}
},
+ "Left alone: another app on this Mac keeps its own data inside, and moving this would take that data too." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nedotčeno: uvnitř si jiná aplikace v tomto Macu uchovává vlastní data a přesunutím by se tato data přesunula také."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Unangetastet: Eine andere App auf diesem Mac bewahrt darin ihre eigenen Daten auf, und ein Verschieben würde diese Daten mitnehmen."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "No se toca: otra app de este Mac guarda dentro sus propios datos, y trasladar esto se llevaría también esos datos."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Laissé en place : une autre app de ce Mac y conserve ses propres données, et le déplacer emporterait aussi ces données."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Resta dov’è: un’altra app su questo Mac conserva i propri dati all’interno, e spostare questo elemento porterebbe con sé anche quei dati."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "対象外: このMacのほかのアプリが自身のデータを中に保管しており、これを移動するとそのデータも一緒に移動してしまいます。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "그대로 둠: 이 Mac의 다른 앱이 안에 자체 데이터를 보관하고 있어서, 이 항목을 이동하면 그 데이터도 함께 이동됩니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Blijft staan: een andere app op deze Mac bewaart er zijn eigen gegevens in, en als dit wordt verplaatst, gaan die gegevens ook mee."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nietknięte: inna aplikacja na tym Macu przechowuje w środku własne dane, a przeniesienie całości przeniosłoby także te dane."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Preservado: outro app deste Mac guarda os próprios dados aqui dentro, e mover isto levaria esses dados também."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Lăsat neatins: o altă aplicație de pe acest Mac își păstrează înăuntru propriile date, iar mutarea acestui articol ar lua și datele respective."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Остается на месте: другое приложение на этом Mac хранит внутри свои данные, и перемещение захватило бы и эти данные."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Rörs inte: en annan app på den här datorn sparar sina egna data i den, och om den flyttades skulle även dessa data följa med."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Yerinde kalır: bu Mac’teki başka bir uygulama kendi verilerini bunun içinde tutuyor ve bunu taşımak o verileri de götürür."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Лишається на місці: інша програма на цьому Mac зберігає всередині власні дані, і переміщення забрало б і ці дані."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "留在原处:这台Mac上的另一个App在其中存放着自己的数据,移动此项会连带移走这些数据。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "原地保留:這部Mac上的其他App在其中存放自己的資料,移動此項目會連帶移動這些資料。"
+ }
+ }
+ }
+ },
"Left alone: macOS installed this system extension and removes it only when the app that uses it goes to the Trash in Finder. If that app is gone, install it again, open it and use the feature that needs the extension, allow it when macOS asks, then move the app to the Trash in Finder and restart your Mac." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
index ce79ee4e..6a338923 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
@@ -337,6 +337,7 @@ extension HoldBack {
case .holdsKeys: "holds a wallet or a key Peel protects"
case .holdsWorkKeptInACache: "holds work an app keeps nowhere else, such as an editor's local history"
case .insideAnotherAppsFolder: "inside another app's folder"
+ case .holdsAnotherAppsData: "holds what another installed app keeps as its own"
case .beyondTheHelper: "needs an administrator, and Peel's helper may not move it"
case .leftToItsUninstaller: "removed by the app's own uninstaller once the app is in the Trash"
case .systemExtension:
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
index 67b92893..e95b5da1 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
@@ -1,4 +1,5 @@
public import Foundation
+internal import PeelPrivileged
public enum MatchReason: String, Sendable, Hashable {
case bundleIdentifier
@@ -95,6 +96,9 @@ public enum HoldBack: String, Sendable, Hashable {
/// installed app or to Apple. It is probably the other app's data about this one, as a documentation browser
/// or a controller app keeps.
case insideAnotherAppsFolder
+ /// Holds what another installed app keeps as its own, as Developer's table names it, such as Xcode's folders in
+ /// `~/Library/Developer`: it goes with that app, never with this one.
+ case holdsAnotherAppsData
/// Needs an administrator, and the helper's own rule refuses it (`HelperReach`).
case beyondTheHelper
/// Removed by the app's own uninstaller once the app has moved (`UninstallsItself`). Moved first, the file of
@@ -133,7 +137,7 @@ public enum HoldBack: String, Sendable, Hashable {
self == .holdsDocuments || self == .holdsALibrary || self == .holdsKeys || self == .holdsWorkKeptInACache
|| self == .beyondTheHelper || self == .leftToItsUninstaller
|| self == .systemExtension || self == .systemExtensionGoingAtRestart || self == .holdsAnExclusion
- || self == .inTheCloud
+ || self == .inTheCloud || self == .holdsAnotherAppsData
}
/// Why what a walk saw leaves a folder to be chosen by hand: a wallet, a signing key, or a repository inside may
@@ -307,6 +311,21 @@ public struct LeftoverScan: Sendable {
)
}
+ /// The same scan, each item holding a place another installed app keeps (`places`) left alone and shared with it.
+ func holdingBack(placesOthersKeep places: [(place: String, app: String)]) -> LeftoverScan {
+ LeftoverScan(
+ leftovers: leftovers.map { leftover in
+ let item = PathPattern.comparablePath(of: leftover.url)
+ let keepers = Set(places.filter { PathComponents.isPath($0.place, atOrInside: item) }.map(\.app))
+ guard !keepers.isEmpty else { return leftover }
+ return leftover.sharing(with: keepers.sorted()).heldBack(.holdsAnotherAppsData)
+ },
+ unreadableLocations: unreadableLocations,
+ cutShortLocations: cutShortLocations,
+ needsFullDiskAccess: needsFullDiskAccess
+ )
+ }
+
func leavingToItsUninstaller(_ app: UninstallsItself) -> LeftoverScan {
LeftoverScan(
leftovers: leftovers.map { app.removes($0.url) ? $0.heldBack(.leftToItsUninstaller) : $0 },
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift
index 809f5d75..c4cbedd2 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift
@@ -37,6 +37,21 @@ struct LeftoverMatcher: Sendable {
.map(\.reference).sorted()
}
+ /// Each place on disk an installed app besides this one, and not a copy of it, keeps as its own, as Developer's
+ /// table names it, with that app.
+ func placesOthersKeep(home: URL) -> [(place: String, app: String)] {
+ let owners = others.filter { !$0.isACopy(of: target) }
+ return DeveloperCaches.definitions.flatMap { definition -> [(place: String, app: String)] in
+ let apps = Set(definition.appBundleIdentifiers.map { $0.lowercased() })
+ guard let owner = owners.first(where: { $0.identifier.map(apps.contains) ?? false }) else { return [] }
+ return definition.folders.filter { $0.base == .home }.flatMap { folder in
+ PathPattern.expand(folder.path, home: home, from: .peel).map {
+ (PathPattern.comparablePath(of: $0), owner.reference)
+ }
+ }
+ }
+ }
+
/// The installed apps besides this one that manage the area, and this app's other copies.
func others(managing area: SpaceInventory.ManagingApps) -> (apps: [String], copies: [URL]) {
let managing = others.filter { area.includes($0.identifier) }
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift b/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift
index 39659336..92e6f4b2 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/Uninstallation.swift
@@ -82,6 +82,7 @@ public struct Uninstallation: Sendable {
environment: environment
)
)
+ scan = scan.holdingBack(placesOthersKeep: matcher.placesOthersKeep(home: environment.homeDirectory))
let uninstallsItself = UninstallsItself.of(app, environment: environment)
if let uninstallsItself {
scan = scan.leavingToItsUninstaller(uninstallsItself)
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift
index 136f6e73..d107134e 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/UninstallationTests.swift
@@ -123,6 +123,37 @@ struct UninstallationTests {
#expect(await RemovedElsewhere.first(among: [filtering], asking: installed(.beingRemoved)) == nil)
}
+ @Test func leavesAloneAFolderHoldingWhatAnotherInstalledAppKeeps() async throws {
+ let directory = try TemporaryDirectory()
+ let home = directory.url.appending(path: "home", directoryHint: .isDirectory)
+ try directory.file("home/Library/Developer/Xcode/DerivedData/Example-abc/info.plist", bytes: 64)
+ let developer = InstalledApp(
+ url: try directory.directory("root/Applications/Developer.app"), bundleIdentifier: "org.example.developer",
+ name: "Developer"
+ )
+ let xcode = InstalledApp(
+ url: try directory.directory("root/Applications/Xcode.app"), bundleIdentifier: "com.apple.dt.Xcode", name: "Xcode"
+ )
+ let environment = SearchEnvironment(
+ homeDirectory: home, rootDirectory: directory.url.appending(path: "root", directoryHint: .isDirectory)
+ )
+ let folder = PathPattern.comparablePath(of: home.appending(path: "Library/Developer"))
+ func plan(installed: [InstalledApp]) async -> Uninstallation {
+ await Uninstallation.prepare(
+ developer, installedApps: installed, systemExtensions: { [] }, environment: environment
+ )
+ }
+
+ let withXcode = await plan(installed: [developer, xcode])
+ let kept = try #require(withXcode.scan.leftovers.first { PathPattern.comparablePath(of: $0.url) == folder })
+ #expect(kept.match.heldBack == .holdsAnotherAppsData)
+ #expect(kept.match.sharedWith == ["com.apple.dt.Xcode"])
+ #expect(!withXcode.selectable(canUseHelper: true).contains(kept.url))
+ let alone = await plan(installed: [developer])
+ let named = alone.scan.leftovers.first { PathPattern.comparablePath(of: $0.url) == folder }
+ #expect(named?.match.heldBack == .namedLikeTheApp)
+ }
+
@Test func severalAppsAskMacOSOnceAndOnlyWhenOneCarriesASystemExtension() async throws {
let directory = try TemporaryDirectory()
let example = try appCarryingAFilter(in: directory)
diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swift
index b8bc0057..0197aa55 100644
--- a/Peel/Views/Presentation.swift
+++ b/Peel/Views/Presentation.swift
@@ -296,6 +296,8 @@ extension HoldBack {
"Peel won’t move this: an app keeps work inside that exists nowhere else, such as an editor’s local history."
case .insideAnotherAppsFolder:
"Not selected: only the name matches, and it sits inside a folder that belongs to macOS or to another installed app, which may be keeping it for itself."
+ case .holdsAnotherAppsData:
+ "Left alone: another app on this Mac keeps its own data inside, and moving this would take that data too."
case .beyondTheHelper:
"Left alone: only an administrator can move this, and Peel’s helper isn’t allowed to move it from here."
case .leftToItsUninstaller:
diff --git a/SAFETY.md b/SAFETY.md
index fb90963d..c18a41e5 100644
--- a/SAFETY.md
+++ b/SAFETY.md
@@ -258,6 +258,9 @@ Only matches Peel is `certain` or `likely` about, and only when nothing else ins
nor its maker, such as another app's, one of Apple's, or a command-line tool's, is shown and never selected, since a
folder of that name may be that program's own; so is something matched by name alone at the top of your home folder
or of a Library, or in a maker's folder there.
+- **Another app's data stays with it.** A folder that holds what another installed app keeps as its own, as the
+ Developer page names it, such as Xcode's folders in `~/Library/Developer`, is listed with that app named and can't
+ be selected: it goes with that app, never with this one.
- **A plug-in goes by what it declares.** Its name says what it does rather than who made it, so a plug-in called
like the app is selected only when the identifier it declares is the app's or its maker's: another maker's plug-in
with the app's name is never selected.