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
Developer lists the browser profiles Playwright left behind
Țugui Dragoș3c947aaca235
diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swiftindex 31c48c39..0ae4d63c 100644--- a/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift+++ b/Packages/PeelCore/Sources/PeelCore/Developer/DeveloperCaches.swift@@ -118,6 +118,9 @@ public enum DeveloperCaches {case home/// The folder macOS gives each user for caches, `getconf DARWIN_USER_CACHE_DIR`.case userCache+ /// The folder macOS gives each user for temporary files, `getconf DARWIN_USER_TEMP_DIR`. What a program+ /// still has open there is never listed: it is in use, not left behind.+ case userTemporary}let path: String@@ -193,8 +196,13 @@ public enum DeveloperCaches {}/// Where the folder is: at `path` in its base, and where the Xcode setting that moves it says.- func places(home: URL, userCache: URL?, preference: (String) -> String?) -> [URL] {- guard let root = base == .home ? home : userCache else { return [] }+ func places(home: URL, userCache: URL?, userTemporary: URL?, preference: (String) -> String?) -> [URL] {+ let root = switch base {+ case .home: home+ case .userCache: userCache+ case .userTemporary: userTemporary+ }+ guard let root else { return [] }var places = PathPattern.expand(path, home: root)if let setting = movedByXcodeSetting.flatMap(preference).map({ NSString(string: $0).expandingTildeInPath }),setting.hasPrefix("/") {@@ -427,6 +435,17 @@ public enum DeveloperCaches {]),Definition(id: "playwright", name: "Playwright", systemImage: "globe", appBundleIdentifiers: [], folders: [Folder("Library/Caches/ms-playwright", .environments, source: "https://github.com/microsoft/playwright/blob/main/docs/src/browsers.md#L958"),+ // A browser's profile and a run's artifacts, which Playwright removes when the browser closes.+ Folder(+ "playwright_*dev_profile-*/", .cache,+ source: "https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/browserType.ts#L171",+ base: .userTemporary+ ),+ Folder(+ "playwright-artifacts-*/", .cache,+ source: "https://github.com/microsoft/playwright/blob/main/packages/playwright-core/src/server/browserType.ts#L161",+ base: .userTemporary+ ),]),Definition(id: "playwrightgo", name: "Playwright for Go", systemImage: "globe", appBundleIdentifiers: [], folders: [Folder("Library/Caches/ms-playwright-go", .environments, source: "https://github.com/playwright-community/playwright-go/blob/main/run.go#L370-L372"),@@ -1044,7 +1063,8 @@ public enum DeveloperCaches {let electron = electronDefinitions(for: apps, home: environment.homeDirectory)return await scan(definitions + electron, homeDirectory: environment.homeDirectory,- userCacheDirectory: environment.userCacheDirectory, exclusions: exclusions+ userCacheDirectory: environment.userCacheDirectory,+ userTemporaryDirectory: environment.userTemporaryDirectory, exclusions: exclusions)}@@ -1086,9 +1106,11 @@ public enum DeveloperCaches {_ definitions: [Definition],homeDirectory: URL,userCacheDirectory: URL? = nil,+ userTemporaryDirectory: URL? = nil,exclusions: Exclusions = .none,measure: @escaping LeftoverScanner.Measure = LeftoverScanner.walk,- preference: @escaping @Sendable (String) -> String? = Self.xcodePreference+ preference: @escaping @Sendable (String) -> String? = Self.xcodePreference,+ openFiles: OpenFiles = OpenFiles()) async -> [DeveloperEnvironment] {await withTaskGroup(of: DeveloperEnvironment?.self) { group infor definition in definitions {@@ -1096,7 +1118,8 @@ public enum DeveloperCaches {var found: [(url: URL, folder: Folder, project: String?)] = []for folder in definition.folders {let places = folder.places(- home: homeDirectory, userCache: userCacheDirectory, preference: preference+ home: homeDirectory, userCache: userCacheDirectory, userTemporary: userTemporaryDirectory,+ preference: preference)let rows = places.flatMap { place infolder.launchers.isEmpty@@ -1112,6 +1135,7 @@ public enum DeveloperCaches {// Skips a symbolic link, which is how people move a big cache to another disk.// Moving the link frees nothing.guard (try? url.resourceValues(forKeys: [.isSymbolicLinkKey]).isSymbolicLink) != true else { continue }+ guard folder.base != .userTemporary || openFiles.holders(of: url).isEmpty else { continue }found.append((url, folder, project))}}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swiftindex b889bd98..0eef9477 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/DeveloperCachesTests.swift@@ -238,7 +238,7 @@ struct DeveloperCachesTests {// The only top-level entries in the table, each owned outright by the one tool that made it.let ownedOutright: Set<String> = [".ccache", ".electron-gyp", ".gitlibs", ".node-gyp", ".virtualenvs", "nltk_data", "tensorflow_datasets",- ".zcompdump*", ".pnpm-store",+ ".zcompdump*", ".pnpm-store", "playwright_*dev_profile-*/", "playwright-artifacts-*/",]for definition in DeveloperCaches.definitions {for path in definition.folders.map(\.path) {@@ -406,7 +406,11 @@ struct DeveloperCachesTests {// that ends in `/` matches every folder beside, so what sits beside its match is a file.let concrete = folder.path.replacingOccurrences(of: "*", with: "match").replacingOccurrences(of: "[0-9a-f]", with: "a")let foldersOnly = concrete.hasSuffix("/")- let base = folder.base == .userCache ? "UserCache/" : ""+ let base = switch folder.base {+ case .home: ""+ case .userCache: "UserCache/"+ case .userTemporary: "UserTemporary/"+ }let entry = base + (foldersOnly ? String(concrete.dropLast()) : concrete)// A folder of versions lists those beside the one its launchers run.if !folder.launchers.isEmpty {@@ -438,7 +442,8 @@ struct DeveloperCachesTests {let userCache = directory.url.appending(path: "UserCache", directoryHint: .isDirectory)let environment = SearchEnvironment(- homeDirectory: directory.url, rootDirectory: directory.url, userCacheDirectory: userCache+ homeDirectory: directory.url, rootDirectory: directory.url, userCacheDirectory: userCache,+ userTemporaryDirectory: directory.url.appending(path: "UserTemporary", directoryHint: .isDirectory))let environments = await DeveloperCaches.scan(in: environment)let home = directory.url.path(percentEncoded: false)@@ -958,6 +963,30 @@ struct DeveloperCachesTests {#expect(locations.first?.kind == .cache)}+ /// Playwright removes the folders it makes in the temporary folder when the browser closes, so one that is still+ /// there was left by a run that ended early, unless a browser still has it open.+ @Test func offersWhatPlaywrightLeftInTheTemporaryFolderAndNothingInUse() async throws {+ let directory = try TemporaryDirectory()+ let temporary = try directory.directory("var/T")+ try directory.file("var/T/playwright_chromiumdev_profile-a1b2c3/Default/Cookies", bytes: 400_000)+ try directory.file("var/T/playwright-artifacts-d4e5f6/trace.zip", bytes: 400_000)+ let live = try directory.file("var/T/playwright_firefoxdev_profile-g7h8i9/places.sqlite", bytes: 400_000)+ try directory.file("var/T/other-tool-profile/data", bytes: 400_000)+ let browser = try FileHandle(forWritingTo: live)+ defer { try? browser.close() }+ let playwright = DeveloperCaches.definitions.filter { $0.id == "playwright" }++ let locations = await DeveloperCaches.scan(+ playwright, homeDirectory: directory.url.appending(path: "home"), userTemporaryDirectory: temporary,+ openFiles: OpenFiles(excluding: nil)+ ).flatMap(\.locations)++ #expect(Set(locations.map(\.url.lastPathComponent)) == [+ "playwright_chromiumdev_profile-a1b2c3", "playwright-artifacts-d4e5f6",+ ])+ #expect(locations.allSatisfy { $0.kind == .cache && $0.isRecommended })+ }+@Test func offersTheSonarScannersCacheAndNeverItsCertificates() async throws {let directory = try TemporaryDirectory()try directory.file(".sonar/cache/0f2e/sonar-scanner-engine-shaded-10.jar", bytes: 400_000)diff --git a/README.md b/README.mdindex 84c6c317..4475aa9c 100644--- a/README.md+++ b/README.md@@ -107,10 +107,11 @@ Peel is free and open source, and it speaks English and 17 other languages.- **Orphaned Files:** files left behind by apps you already removed.- **Developer:** caches of Xcode, package managers, build systems, editors, cloud and virtual machine tools, gameengines, and AI models, the graphics caches of Chrome, Chromium, Brave, and Opera, and the web caches of apps built- on Electron, such as Slack or Discord (never what a browser or an app keeps for you). Xcode's archives and the- symbols it copied from your devices, model weights, installed packages, and what a tool keeps for you to install- again (Vagrant boxes, Asset Store packages) are listed but never selected for you, and toolchains or anything- holding an account are never listed.+ on Electron, such as Slack or Discord (never what a browser or an app keeps for you), and the browser profiles a+ Playwright run left in the temporary folder when it ended early, never one a browser still has open. Xcode's+ archives and the symbols it copied from your devices, model weights, installed packages, and what a tool keeps for+ you to install again (Vagrant boxes, Asset Store packages) are listed but never selected for you, and toolchains or+ anything holding an account are never listed.- **Build Artifacts:** what builds left in the folders you choose, like `node_modules`, `DerivedData`, `target`,`.nuxt`, `__pycache__`, Unity's `Library`, and any folder its tool tagged as a cache (`CACHEDIR.TAG`), each onlywhen a file of the tool that makes it proves it. A project changed in the last 7 days is never selected for you, and