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
Orphaned Files finds what a removed app kept under its own name
Țugui Dragoșf905136580ac
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 0e5476c5..633d6856 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -72987,6 +72987,112 @@}}},+ "Only the name ties these to %@, which Peel saw installed" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Jen název je spojuje s aplikací %@, kterou Peel viděl nainstalovanou"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nur der Name verbindet diese mit der App „%@“, die Peel installiert vorgefunden hat"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Solo el nombre los vincula a %@, que Peel vio instalada"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Seul le nom relie ces fichiers à %@, que Peel a vu installé"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Solo il nome li lega a %@, che Peel ha visto installata"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peelがインストールを確認した“%@”とは名前だけでつながっています"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "이 항목은 Peel이 설치를 확인한 ‘%@’과(와) 이름으로만 연결됨"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Alleen de naam koppelt deze aan %@, die Peel geïnstalleerd zag"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Z aplikacją %@, którą Peel widział zainstalowaną, łączy je tylko nazwa"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Só o nome liga estes itens a %@, que o Peel viu instalado"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Doar numele le leagă de aplicația %@, pe care Peel a văzut‑o instalată"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "С приложением «%@», которое Peel видел установленным, их связывает только имя"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bara namnet knyter dessa till %@, som Peel såg installerad"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bunları Peel’in yüklü olarak gördüğü %@ uygulamasına yalnızca adları bağlıyor"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Лише назва повʼязує їх із програмою «%@», яку Peel бачила інстальованою"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "这些文件仅凭名称与Peel曾看到已安装的“%@”关联"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "只有名稱將這些項目與Peel曾看到已安裝的「%@」關聯在一起"+ }+ }+ }+ },"Open %@" : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex 8a206456..fd27b71b 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -292,6 +292,7 @@ extension OrphanConfidence {switch reasons.first {case .running: "something with this identifier is running now"case .leadsIntoAnAppThatIsGone: "these links lead into an app that is no longer there"+ case .onlyTheName(let name): "only the name ties these to \(Output.plain(name)), which Peel saw installed"case .writtenRecently(let date): "something wrote here on \(Output.day(date))"case .writtenAfterItLeft(let name, let written): "something wrote here on \(Output.day(written)), after Peel last saw \(Output.plain(name)) installed"case .sameMakerStillInstalled: "an app from the same maker is still installed"diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swiftindex 36bc6cc7..c072adb6 100644--- a/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/Orphan.swift@@ -11,6 +11,8 @@ public struct OrphanItem: Sendable, Hashable, Identifiable {/// Why the item is left for the user to choose by hand, or nil. Select All passes it by, and `peel orphans/// --remove` leaves it where it is.public var heldBack: HoldBack?+ /// The bundle identifier of the app that left, when the item bears its name and nothing else ties the two.+ public var namedAfter: String?/// Why the item cannot be selected at all: `RemovalGuard` or the helper would refuse it.public var leftAlone: HoldBack? {diff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swiftindex bb6d771e..d3b7ff85 100644--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanConfidence.swift@@ -34,6 +34,8 @@ public struct OrphanConfidence: Sendable, Hashable {case running/// Links into an app that is gone, so they lead nowhere.case leadsIntoAnAppThatIsGone+ /// Only the name of an app Peel saw installed ties these files to it.+ case onlyTheName(of: String)/// Nothing installed claims the identifier, which is all Peel can say.case nothingClaimsIt}@@ -66,6 +68,9 @@ public struct OrphanConfidence: Sendable, Hashable {if group.items.allSatisfy({ $0.kind == .commandLineTools }) {return OrphanConfidence(level: .certain, reasons: [.leadsIntoAnAppThatIsGone])}+ if let app = group.rememberedApp, group.items.allSatisfy({ $0.namedAfter != nil }) {+ return OrphanConfidence(level: .unsure, reasons: [.onlyTheName(of: app.name)])+ }let makerIsStillHere = group.rememberedApp?.teamIdentifier.map(installedTeams.contains) ?? false// A folder's own date changes when files are taken out of it, so the last write on a leftover is often// the uninstall itself. If nothing was written later than `settling` after Peel last saw the app, adiff --git a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swiftindex 56ad644f..c2301964 100644--- a/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift+++ b/Packages/PeelCore/Sources/PeelCore/Orphans/OrphanScanner.swift@@ -56,12 +56,16 @@ public struct OrphanScanner: Sendable {)let goneApps = gone.map { $0.bundleIdentifier.lowercased() }+ let goneNames = Dictionary(gone.map { ($0.name.lowercased(), $0.bundleIdentifier) }, uniquingKeysWith: { first, _ in first })let results = await withTaskGroup(of: LocationResult.self) { group inlet home = environment.homeDirectory.path(percentEncoded: false)for location in environment.locations {_ = group.addTaskUnlessCancelled { [walk] in- await Self.scan(location, ownership: ownership, jobs: jobs, goneBundles: goneBundles, goneApps: goneApps, home: home, walk: walk)+ await Self.scan(+ location, ownership: ownership, jobs: jobs, goneBundles: goneBundles, goneApps: goneApps,+ goneNames: goneNames, home: home, walk: walk+ )}}return await group.reduce(into: [LocationResult]()) { $0.append($1) }@@ -100,8 +104,13 @@ public struct OrphanScanner: Sendable {let ownership = AppOwnership(installedApps: installedApps + systemApps, isRegisteredApp: isRegisteredApp)let jobs = BackgroundItemOwnership(installedApps: installedApps + systemApps)var kept: [OrphanItem] = []- for item in items where await Self.orphanIdentifier(of: item.url, kind: item.kind, ownership: ownership, jobs: jobs) != nil {- kept.append(item)+ for item in items {+ let isStillOrphaned = if let app = item.namedAfter {+ await Self.goneApp(named: item.url, kind: item.kind, goneNames: [item.url.lastPathComponent.lowercased(): app], ownership: ownership) != nil+ } else {+ await Self.orphanIdentifier(of: item.url, kind: item.kind, ownership: ownership, jobs: jobs) != nil+ }+ if isStillOrphaned { kept.append(item) }}return kept}@@ -241,6 +250,23 @@ public struct OrphanScanner: Sendable {return identifier}+ /// The places where an app keeps a folder under its own name, such as `Caches/Figma`, and nothing it keeps+ /// there is the person's own work.+ static let namedPlaces: Set<SearchLocation.Kind> = [+ .caches, .logs, .savedApplicationState, .httpStorages, .webKit, .applicationSupport,+ ]++ /// The app that left whose name `url` bears, in one of `namedPlaces`, while no installed app claims that name.+ static func goneApp(named url: URL, kind: SearchLocation.Kind, goneNames: [String: String], ownership: AppOwnership) async -> String? {+ let name = url.lastPathComponent+ guard+ namedPlaces.contains(kind), !isSensitive(fileName: name),+ let app = goneNames[name.lowercased()],+ !ownership.isClaimed(fileName: name, kind: kind, identifier: app)+ else { return nil }+ return await holdsFilesOfAnInstalledApp(url, kind: kind, ownership: ownership) ? nil : app+ }+/// Whether a plug-in came with an app Peel saw go: its identifier is that app's, extends it, or is its maker's./// An installer can put a plug-in in place with no app at all, and its date does not move when it is used, so/// nothing else says it was left behind.@@ -263,6 +289,7 @@ public struct OrphanScanner: Sendable {jobs: BackgroundItemOwnership,goneBundles: [String: String],goneApps: [String],+ goneNames: [String: String],home: String,walk: LeftoverScanner.Measure) async -> LocationResult {@@ -284,7 +311,13 @@ public struct OrphanScanner: Sendable {guard isAFileAFolderOrALink(url) else { continue }// What the guard refuses outright is never listed, whether an installed app claims it or not.guard !ProtectedData.refuses(url.path(percentEncoded: false), home: home) else { continue }- guard let identifier = await orphanIdentifier(of: url, kind: location.kind, ownership: ownership, jobs: jobs, goneBundles: goneBundles) else { continue }+ var namedAfter: String?+ var identifier = await orphanIdentifier(of: url, kind: location.kind, ownership: ownership, jobs: jobs, goneBundles: goneBundles)+ if identifier == nil {+ namedAfter = await goneApp(named: url, kind: location.kind, goneNames: goneNames, ownership: ownership)+ identifier = namedAfter+ }+ guard let identifier else { continue }guard location.kind != .plugIns || cameWithAnAppThatLeft(identifier, goneApps: goneApps) else { continue }// The item's own date changes when something is taken out of it, but not when a file inside is@@ -301,6 +334,7 @@ public struct OrphanScanner: Sendable {} else {// `/Users/Shared` belongs to every account on the Mac, and the other accounts' apps are not known here.HoldBack.seen(in: contents) ?? (location.kind == .sharedFolder ? .sharedWithEveryone : nil)+ ?? (namedAfter != nil ? .namedLikeTheApp : nil)}let item = OrphanItem(url: url,@@ -308,7 +342,8 @@ public struct OrphanScanner: Sendable {size: contents.flatMap { $0.couldNotBeRead ? nil : $0.size },modificationDate: [own, contents?.newestChange].compactMap(\.self).max(),requiresPrivileges: parent.requiresPrivileges(toRemove: url),- heldBack: heldBack+ heldBack: heldBack,+ namedAfter: namedAfter)found.append((identifier, item))}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swiftindex c5d39d10..51e370b3 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift@@ -219,6 +219,35 @@ struct OrphanScannerTests {#expect(still.map(\.url.lastPathComponent) == ["com.gone.app"])}+ @Test func findsWhatAnAppThatLeftKeptUnderItsNameAndSelectsNone() async throws {+ let directory = try TemporaryDirectory()+ try directory.file("home/Library/Caches/Figma/index.db", bytes: 50_000)+ try directory.file("home/Library/Logs/Figma/main.log")+ try directory.file("home/Library/Application Support/Figma/settings.json")+ try directory.file("home/Library/Preferences/Figma.plist")+ try directory.file("home/Library/Caches/Installed/cache.db")+ try directory.file("home/Library/Caches/Sketchbook/cache.db")+ let figma = RememberedApp(+ bundleIdentifier: "com.figma.Desktop", name: "Figma", teamIdentifier: nil,+ lastSeen: .now.addingTimeInterval(-90 * 24 * 60 * 60), lastPath: "/Applications/Figma.app"+ )+ let scanner = scanner(in: directory)++ let groups = await scanner.scan(installedApps: installed, remembered: [figma]).groups++ #expect(groups.map(\.identifier) == ["com.figma.Desktop"])+ let group = try #require(groups.first)+ #expect(Set(group.items.map { "\($0.kind.rawValue)/\($0.url.lastPathComponent)" }) == [+ "caches/Figma", "logs/Figma", "applicationSupport/Figma",+ ])+ #expect(group.items.allSatisfy { $0.heldBack == .namedLikeTheApp && $0.namedAfter == "com.figma.Desktop" })+ #expect(group.confidence == OrphanConfidence(level: .unsure, reasons: [.onlyTheName(of: "Figma")]))++ #expect(await scanner.stillOrphaned(group.items, installedApps: installed).count == 3)+ let back = InstalledApp(url: URL(filePath: "/Applications/Figma.app"), bundleIdentifier: "com.figma.Desktop2", name: "Figma")+ #expect(await scanner.stillOrphaned(group.items, installedApps: installed + [back]).isEmpty)+ }+@Test func reportsOnlyUnclaimedAppItems() async throws {let directory = try TemporaryDirectory()try directory.file("home/Library/Preferences/com.gone.app.plist")diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex 27421563..b1ff8363 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -234,6 +234,8 @@ extension OrphanConfidence {Text("Something with this identifier is running now")case .leadsIntoAnAppThatIsGone:Text("These links lead into an app that is no longer there")+ case .onlyTheName(let name):+ Text("Only the name ties these to \(name), which Peel saw installed")case .writtenRecently(let date):wroteHere(date)case .writtenAfterItLeft(let name, let written):