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
Take an Electron app's name as written when looking for its caches
Țugui Dragoș5a77eea651fd
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swiftindex 43e7be19..9cb8305f 100644--- a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift+++ b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift@@ -1316,8 +1316,8 @@ public enum DeveloperCaches {let name = editor ?? bundleNameguard !name.isEmpty, !name.contains("/"), name != ".", name != "..", !covered.contains(name.lowercased())else { return nil }- let data = "Library/Application Support/\(name)"- guard exists(home.appending(path: "\(data)/Local State")) else { return nil }+ guard exists(home.appending(path: "Library/Application Support/\(name)/Local State")) else { return nil }+ let data = "Library/Application Support/\(PathPattern.literal(name))"// Each persistent session an app opens keeps the same caches in a folder of its own.let partitions = "\(data)/Partitions/*"let partition = electron + "electron_browser_context.cc#L384-L390"diff --git a/Packages/PeelCore/Sources/PeelCore/Support/PathPattern.swift b/Packages/PeelCore/Sources/PeelCore/Support/PathPattern.swiftindex a61e24d5..eafda67c 100644--- a/Packages/PeelCore/Sources/PeelCore/Support/PathPattern.swift+++ b/Packages/PeelCore/Sources/PeelCore/Support/PathPattern.swift@@ -100,6 +100,18 @@ public enum PathPattern {case cask}+ /// `name` written into a `.peel` pattern so that it matches only itself. Peel's patterns are read without+ /// backslash escapes, so each `*`, `?` and `[` goes inside brackets of its own.+ static func literal(_ name: String) -> String {+ name.reduce(into: "") { text, character in+ if "*?[".contains(character) {+ text += "[\(character)]"+ } else {+ text.append(character)+ }+ }+ }+private static let entriesAStarReads = 16_384/// The existing files `pattern` names, leaving out irreplaceable ones (`isIrreplaceable`). A pattern without adiff --git a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swiftindex 1565aa6e..a1e22588 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift@@ -323,6 +323,33 @@ struct DeveloperCachesTests {#expect(DeveloperCaches.electronDefinitions(for: apps, home: home).isEmpty)}+ @Test func takesAnElectronAppsNameAsWrittenWhereItsFoldersAreLookedFor() async throws {+ let directory = try TemporaryDirectory()+ let home = directory.url.appending(path: "home", directoryHint: .isDirectory)+ let apps = try [("Chat [Beta]", "beta"), ("*", "star")].map { name, identifier in+ try directory.directory("Applications/\(identifier).app/Contents/Frameworks/Electron Framework.framework")+ try directory.file("home/Library/Application Support/\(name)/Local State")+ try directory.file("home/Library/Application Support/\(name)/Partitions/team/Cache/index", bytes: 4_096)+ return InstalledApp(+ url: directory.url.appending(path: "Applications/\(identifier).app", directoryHint: .isDirectory),+ bundleIdentifier: "org.example.\(identifier)", name: name, bundleName: name+ )+ }+ try directory.file("home/Library/Application Support/Chat B/Partitions/team/Cache/index", bytes: 4_096)+ try directory.file("home/Library/Application Support/Other/Cache/index", bytes: 4_096)++ let environments = await DeveloperCaches.scan(+ DeveloperCaches.electronDefinitions(for: apps, home: home), homeDirectory: home+ )++ let listed = { (identifier: String) in+ let environment = environments.first { $0.appBundleIdentifiers == ["org.example.\(identifier)"] }+ return environment?.locations.map { $0.url.pathComponents.suffix(4).joined(separator: "/") } ?? []+ }+ #expect(listed("beta") == ["Chat [Beta]/Partitions/team/Cache"])+ #expect(listed("star") == ["*/Partitions/team/Cache"])+ }+@Test func listsTheCachesOfAnElectronAppsPartitionsAndNeverTheirStorage() async throws {let directory = try TemporaryDirectory()let home = directory.url.appending(path: "home", directoryHint: .isDirectory)