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
Find what an app hides behind a dot before its identifier
Țugui Dragoș1e8f60fc2540
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swiftindex fc3d6393..fbbbe92b 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverMatcher.swift@@ -34,7 +34,7 @@ struct LeftoverMatcher: Sendable {/// This app's claim on the item called `fileName` in a location of `kind`, found at `url` when the caller knows it.func match(fileName: String, kind: SearchLocation.Kind, at url: URL? = nil) -> LeftoverMatch? {let key = Self.key(from: fileName, kind: kind)- // A hidden file outside the home folder is the system's own: `.GlobalPreferences.plist` is the global domain.+ // A name still hidden here is the system's own: `.GlobalPreferences.plist` is the global domain.guard !key.hasPrefix(".") else { return nil }let candidate = Candidate(key)guard let evidence = target.evidence(for: candidate) else { return nil }@@ -133,10 +133,16 @@ struct LeftoverMatcher: Sendable {case .hiddenHomeFiles:fileName.hasPrefix(".") ? String(fileName.dropFirst()) : fileNamedefault:- fileName+ withoutTheDotBeforeAnIdentifier(fileName)}}+ /// An app hides a folder of its own by writing a dot before its identifier: `.com.example.app.backups`.+ private static func withoutTheDotBeforeAnIdentifier(_ fileName: String) -> String {+ let rest = String(fileName.dropFirst())+ return fileName.hasPrefix(".") && Identifier.isReverseDNS(rest) ? rest : fileName+ }+/// The name a recent documents list carries without its extension, `sfl` and the version macOS writes it in/// (`.sfl4` on macOS 26), whichever version that is.static func withoutRecentDocumentsExtension(_ fileName: String) -> String {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swiftindex d61ec197..f32acbdf 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swift@@ -476,8 +476,9 @@ struct LeftoverMatcherTests {#expect(match("ABCDE12345.com.example.tool", in: .groupContainers, for: app("com.example.tool", name: "Tool", team: "ABCDE12345", groups: ["ABCDE12345.com.example.tool"]))?.confidence == .certain)}- /// A hidden file outside the home folder is the system's own: `.GlobalPreferences.plist` is the global domain.- @Test func neverMatchesAHiddenFileOutsideTheHomeFolder() {+ /// A hidden file outside the home folder is the system's own (`.GlobalPreferences.plist` is the global domain),+ /// unless an app's identifier follows the dot. A hidden settings file is never a domain `defaults` reads.+ @Test func matchesAHiddenFileOutsideTheHomeFolderOnlyByTheIdentifierAfterItsDot() {let named = app("com.example.tool", name: "Global Preferences")let identified = app(".GlobalPreferences", name: "Tool")@@ -487,6 +488,14 @@ struct LeftoverMatcherTests {#expect(match(".GlobalPreferences", in: .applicationSupport, for: target) == nil)}#expect(match(".globalpreferences", in: .hiddenHomeFiles, for: named) != nil)++ let example = app("org.example.app", name: "Example")+ let backups = match(".org.example.app.backups", in: .applicationSupport, for: example)+ #expect(backups?.reason == .bundleIdentifierPrefix)+ #expect(backups?.isRecommended == true)+ #expect(match(".org.example.app", in: .caches, for: example)?.reason == .bundleIdentifier)+ #expect(match(".example", in: .applicationSupport, for: example) == nil)+ #expect(match(".org.example.app.plist", in: .preferences, for: example) == nil)}@Test func aPlugInIsMatchedWithoutTheExtensionThatSaysItsKind() throws {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swiftindex bfa6941d..c45d6608 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift@@ -29,6 +29,27 @@ struct LeftoverScannerTests {#expect(LeftoverScanner.merged([found(in: recent), found(in: support)]).map(\.kind) == [.recentDocuments])}+ @Test func findsAFolderAnAppHidWithADotBeforeItsIdentifier() async throws {+ let directory = try TemporaryDirectory()+ try directory.directory("home/Library/Application Support/.org.example.app.backups")+ try directory.file("home/Library/Preferences/.org.example.app.plist")+ let environment = SearchEnvironment(+ homeDirectory: directory.url.appending(path: "home", directoryHint: .isDirectory),+ rootDirectory: directory.url.appending(path: "root", directoryHint: .isDirectory)+ )+ let app = InstalledApp(+ url: try directory.directory("root/Applications/Example.app"),+ bundleIdentifier: "org.example.app",+ name: "Example"+ )++ let plan = await Uninstallation.prepare(app, installedApps: [app], environment: environment)++ let backups = try #require(plan.scan.leftovers.first { $0.url.lastPathComponent == ".org.example.app.backups" })+ #expect(plan.suggestedSelection(canUseHelper: false).contains(backups.url))+ #expect(!plan.scan.leftovers.contains { $0.url.lastPathComponent == ".org.example.app.plist" })+ }+/// Folders that no app claims are looked into one at a time, so the scan has to notice a stop between them.@Test func aStoppedScanStops() async throws {let directory = try TemporaryDirectory()diff --git a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swiftindex 2c416b4e..89184692 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/OrphanScannerTests.swift@@ -376,6 +376,17 @@ struct OrphanScannerTests {#expect(scan.unreadableLocations.isEmpty)}+ @Test func findsAFolderAnAppThatLeftHidWithADotBeforeItsIdentifier() async throws {+ let directory = try TemporaryDirectory()+ try directory.directory("home/Library/Application Support/.com.gone.app.backups")+ try directory.directory("home/Library/Application Support/.com.installed.app.backups")++ let scan = await scanner(in: directory).scan(installedApps: installed)++ #expect(scan.groups.map(\.identifier) == ["com.gone.app.backups"])+ #expect(scan.groups.first?.items.map(\.url.lastPathComponent) == [".com.gone.app.backups"])+ }+/// A location closed by ordinary permissions is reported, but Full Disk Access would not open it, so the scan/// does not ask for it.@Test(.permissionsHold) func aLocationClosedByPermissionsDoesNotAskForFullDiskAccess() async throws {