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 the folders an app names after the last part of its identifier
Țugui Dragoșf403d5e9cc29
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 1da88bff..d5cd95e5 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -159,6 +159,8 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.Services: Peel draws its icon from the app's own files.- While a removal of many items goes on, Peel reads again, once a second, which programs hold a file open, so a file anapp opened meanwhile stays where it is.+- The folders an app names after the last part of its identifier, its name with a version right after it, are found too,+ such as Folx's `Folx3` folder and log and iTerm2's folder in Application Support.- An app's page, `peel leftovers`, and `peel uninstall` no longer say Peel couldn't look inside a folder named byanother program's identifier, such as Microsoft AutoUpdate's cache in `/Library/Caches`: it holds nothing of theapp's.diff --git a/Packages/PeelCore/Sources/PeelCore/Apps/InstalledApp.swift b/Packages/PeelCore/Sources/PeelCore/Apps/InstalledApp.swiftindex 489bccdf..5e558cdb 100644--- a/Packages/PeelCore/Sources/PeelCore/Apps/InstalledApp.swift+++ b/Packages/PeelCore/Sources/PeelCore/Apps/InstalledApp.swift@@ -182,6 +182,17 @@ public struct InstalledApp: Sendable, Hashable, Identifiable {for name in names {if let withoutVersion = Naming.withoutTrailingVersion(name) { names.insert(withoutVersion) }}+ // The identifier's last part when it is one of these names with a version right after it, as Folx's+ // `com.eltima.Folx3` names its `Folx3` folders. A number after any other name stays part of that name.+ if let last = bundleIdentifier?.split(separator: ".").last.map(String.init) {+ let word = last.lowercased()+ let isANameAndAVersion = names.contains { name in+ let name = name.lowercased()+ return word.count > name.count && word.hasPrefix(name)+ && word.dropFirst(name.count).allSatisfy { $0.isASCII && $0.isNumber }+ }+ if isANameAndAVersion { names.insert(last) }+ }return names}diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/KeptOnlyHere.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/KeptOnlyHere.swiftindex 8085202f..0bf6c783 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/KeptOnlyHere.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/KeptOnlyHere.swift@@ -75,6 +75,9 @@ enum KeptOnlyHere {("Library/Application Support/Motrix", "download.session", .holdsTorrents),// WebTorrent's `TORRENT_PATH`.("Library/Application Support/WebTorrent", "Torrents", .holdsTorrents),+ // Folx's own code: its list of downloads in `Folx3`, and before it `Folx` with `TorrentFiles`.+ ("Library/Application Support/Eltima Software/Folx3", nil, .holdsTorrents),+ ("Library/Application Support/Eltima Software/Folx", nil, .holdsTorrents),// Docker's `docker login`: with no credential store, the credentials go in `.docker/config.json`.(".docker", "config.json", .holdsSignIns),// Cargo's `cargo login`: the token is saved in `$CARGO_HOME/credentials.toml`, and `CARGO_HOME` is `.cargo`.diff --git a/Packages/PeelCore/Tests/PeelCoreTests/KeptOnlyHereTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/KeptOnlyHereTests.swiftindex c4bf8b82..a9c6f989 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/KeptOnlyHereTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/KeptOnlyHereTests.swift@@ -44,6 +44,8 @@ struct KeptOnlyHereTests {(".config/deluge", .holdsTorrents), (".config/deluge/state/torrents.fastresume", .holdsTorrents),("Library/Application Support/Motrix/download.session", .holdsTorrents),("Library/Application Support/WebTorrent/Torrents/1a2b.torrent", .holdsTorrents),+ ("Library/Application Support/Eltima Software/Folx3/Folx3Data.storedata", .holdsTorrents),+ ("Library/Application Support/Eltima Software/Folx/TorrentFiles/1a2b.torrent", .holdsTorrents),(".docker", .holdsSignIns), (".docker/config.json", .holdsSignIns),(".cargo/credentials.toml", .holdsSignIns), (".pypirc", .holdsSignIns),(".gem/credentials", .holdsSignIns), (".local/share/gem/credentials", .holdsSignIns),@@ -79,6 +81,7 @@ struct KeptOnlyHereTests {"Library/Application Support/Motrix/dht.dat", "Library/Application Support/WebTorrent/Posters","Library/Caches/LibreOffice", "Library/Application Support/LibreOffice Beta","Library/Application Support/iTerm2/version.txt", "Library/Caches/com.googlecode.iterm2",+ "Library/Application Support/Eltima Software", "Library/Application Support/Eltima Software/Elmedia Player",]for path in free {#expect(KeptOnlyHere.reason(for: "\(home)/\(path)", home: home, root: "/") == nil, "\(path)")diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swiftindex 097f5cc9..5b02434f 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverMatcherTests.swift@@ -487,6 +487,21 @@ struct LeftoverMatcherTests {#expect(Naming.withoutAttachedVersion("Studio2025.1.") == nil)}+ @Test func matchesAFolderNamedByTheIdentifiersLastPartWhenItIsTheNameAndAVersion() {+ let folx = InstalledApp(+ url: URL(filePath: "/Applications/Folx.app"), bundleIdentifier: "org.example.Folx3", name: "Folx"+ )+ let matcher = LeftoverMatcher(app: folx, installedApps: [folx])+ let other = InstalledApp(+ url: URL(filePath: "/Applications/Folx.app"), bundleIdentifier: "org.example.Downloader3", name: "Folx"+ )++ #expect(matcher.match(fileName: "Folx3", kind: .applicationSupport)?.reason == .name)+ #expect(matcher.match(fileName: "Folx3.log", kind: .logs)?.reason == .name)+ #expect(matcher.match(fileName: "Folx4", kind: .applicationSupport) == nil)+ #expect(LeftoverMatcher(app: other, installedApps: [other]).match(fileName: "Downloader3", kind: .caches) == nil)+ }+/// Only a trailing number counts as a version, so a name that ends in a word is kept whole.@Test func keepsTheWholeNameWhenTheLastWordIsNotAVersion() {#expect(Naming.withoutTrailingVersion("MuseScore 4") == "MuseScore")diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swiftindex 7bbb7c8c..4e94e866 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift@@ -1984,6 +1984,21 @@ struct LeftoverScannerTests {#expect(manifests["com.example.bridge.json"]?.match.isRecommended == true)}+ @Test func findsTheFoldersAnAppNamesAfterTheLastPartOfItsIdentifier() async throws {+ let directory = try TemporaryDirectory()+ try directory.file("home/Library/Application Support/Eltima Software/Folx3/Folx3Data.storedata")+ try directory.file("home/Library/Logs/Folx3.log")+ let folx = InstalledApp(+ url: URL(filePath: "/Applications/Folx.app"), bundleIdentifier: "org.example.Folx3", name: "Folx"+ )++ let scan = await LeftoverScanner(environment: environment(in: directory)).scan(folx, installedApps: [folx])+ let found = Dictionary(uniqueKeysWithValues: scan.leftovers.map { ($0.url.lastPathComponent, $0.match) })++ #expect(found["Folx3.log"]?.isRecommended == true)+ #expect(found["Folx3"]?.heldBack == .holdsTorrents)+ }+@Test func anOfficeSuitesUserProfileIsNotSelected() async throws {let directory = try TemporaryDirectory()try directory.file("home/Library/Application Support/LibreOffice/4/user/template/Letter.ott")