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
Hold back the logs macOS writes for its own services
Țugui Dragoșe923b33f5b08
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 799a7b8b..039e5d5a 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -214,6 +214,8 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.- App Caches no longer selects what macOS keeps there for itself under a plain name, such as the picture of your AppleAccount or Setup Assistant's cache, and Hidden App Caches leaves out two more of macOS's own audio services.+- Logs no longer selects the logs macOS writes for its own services, such as Siri's in `~/Library/Logs/Assistant` and+ those named `com.apple.`: as App Caches does with macOS's caches, it lists them and leaves them unselected.#### Duplicates and File Searchdiff --git a/GUIDE.md b/GUIDE.mdindex f94fc3f5..1380870a 100644--- a/GUIDE.md+++ b/GUIDE.md@@ -175,7 +175,8 @@ deletes for good. Once Xcode is gone, the Simulators area says to install it agaLibrary at the top of the disk, Space also lists the caches and logs apps keep for every account, and the crashreports macOS keeps. Those an administrator owns go through Peel's helper, and what macOS keeps there for its ownservices is never listed. In your own Logs, the folder macOS saves crash reports in stays and only the reports are-offered, since macOS can't make that folder again. The logs Homebrew's services write in `/opt/homebrew/var/log` are+offered, since macOS can't make that folder again. What macOS keeps for its own services in your own Caches and Logs+is listed, and Select Recommended passes it by. The logs Homebrew's services write in `/opt/homebrew/var/log` areoffered file by file, and the folders they sit in stay, since a service expects to find the folder it writes in.Where Developer knows part of a folder, Space says how much of it moves here and opens Developer for the rest. Spacealso explains the snapshots macOS keeps on the disk, which Peel never removes, and, on macOS 27, says how muchdiff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex b2bf7bc7..76929011 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -92825,108 +92825,108 @@}}},- "Not selected: macOS keeps this cache for its own services, which may be using it right now." : {+ "Not selected: macOS keeps this for its own services, which may be using it right now." : {"localizations" : {"cs" : {"stringUnit" : {"state" : "translated",- "value" : "Nevybráno: systém macOS si tuto mezipaměť uchovává pro své vlastní služby, které ji možná právě teď používají."+ "value" : "Nevybráno: systém macOS si tuto položku uchovává pro své vlastní služby, které ji možná právě teď používají."}},"de" : {"stringUnit" : {"state" : "translated",- "value" : "Nicht ausgewählt: macOS bewahrt diesen Cache für seine eigenen Dienste auf, die ihn möglicherweise gerade verwenden."+ "value" : "Nicht ausgewählt: macOS bewahrt dieses Objekt für seine eigenen Dienste auf, die es möglicherweise gerade verwenden."}},"es" : {"stringUnit" : {"state" : "translated",- "value" : "Sin seleccionar: macOS guarda esta caché para sus propios servicios, que podrían estar usándola ahora mismo."+ "value" : "Sin seleccionar: macOS guarda esto para sus propios servicios, que podrían estar usándolo ahora mismo."}},"fr" : {"stringUnit" : {"state" : "translated",- "value" : "Non sélectionné : macOS conserve ce cache pour ses propres services, qui l’utilisent peut-être en ce moment."+ "value" : "Non sélectionné : macOS conserve cet élément pour ses propres services, qui l’utilisent peut-être en ce moment."}},"it" : {"stringUnit" : {"state" : "translated",- "value" : "Non selezionato: macOS conserva questa cache per i propri servizi, che potrebbero usarla proprio ora."+ "value" : "Non selezionato: macOS lo conserva per i propri servizi, che potrebbero usarlo proprio ora."}},"ja" : {"stringUnit" : {"state" : "translated",- "value" : "未選択: このキャッシュはmacOSが自身のサービスのために保持しているもので、現在使用中の可能性があります。"+ "value" : "未選択: これはmacOSが自身のサービスのために保持しているもので、現在使用中の可能性があります。"}},"ko" : {"stringUnit" : {"state" : "translated",- "value" : "선택되지 않음: macOS가 자체 서비스를 위해 이 캐시를 보관하며, 해당 서비스가 지금 이 캐시를 사용하고 있을 수 있습니다."+ "value" : "선택되지 않음: macOS가 자체 서비스를 위해 이 항목을 보관하며, 해당 서비스가 지금 이 항목을 사용하고 있을 수 있습니다."}},"nl" : {"stringUnit" : {"state" : "translated",- "value" : "Niet geselecteerd: macOS bewaart deze cache voor zijn eigen diensten, die hem misschien op dit moment gebruiken."+ "value" : "Niet geselecteerd: macOS bewaart dit voor zijn eigen diensten, die het misschien op dit moment gebruiken."}},"pl" : {"stringUnit" : {"state" : "translated",- "value" : "Nie zaznaczono: macOS przechowuje tę pamięć podręczną na potrzeby własnych usług, które mogą z niej właśnie korzystać."+ "value" : "Nie zaznaczono: macOS przechowuje tę rzecz na potrzeby własnych usług, które mogą z niej właśnie korzystać."}},"pt" : {"stringUnit" : {"state" : "translated",- "value" : "Não selecionado: o macOS mantém este cache para os próprios serviços, que podem estar usando-o neste momento."+ "value" : "Não selecionado: o macOS mantém este item para os próprios serviços, que podem estar usando-o neste momento."}},"ro" : {"stringUnit" : {"state" : "translated",- "value" : "Neselectat: macOS păstrează această memorie tampon pentru propriile servicii, care o pot utiliza chiar acum."+ "value" : "Neselectat: macOS păstrează acest articol pentru propriile servicii, care îl pot utiliza chiar acum."}},"ru" : {"stringUnit" : {"state" : "translated",- "value" : "Не выбрано: macOS хранит этот кэш для своих служб, которые, возможно, используют его прямо сейчас."+ "value" : "Не выбрано: macOS хранит этот объект для своих служб, которые, возможно, используют его прямо сейчас."}},"sv" : {"stringUnit" : {"state" : "translated",- "value" : "Inte markerad: macOS behåller den här cachen för sina egna tjänster, som kanske använder den just nu."+ "value" : "Inte markerad: macOS behåller det här för sina egna tjänster, som kanske använder det just nu."}},"tr" : {"stringUnit" : {"state" : "translated",- "value" : "Seçilmedi: macOS bu önbelleği kendi hizmetleri için tutuyor; bunlar şu anda onu kullanıyor olabilir."+ "value" : "Seçilmedi: macOS bu öğeyi kendi hizmetleri için tutuyor; bunlar şu anda onu kullanıyor olabilir."}},"uk" : {"stringUnit" : {"state" : "translated",- "value" : "Не вибрано: macOS зберігає цей кеш для власних служб, які можуть саме зараз ним користуватися."+ "value" : "Не вибрано: macOS зберігає цей елемент для власних служб, які можуть саме зараз ним користуватися."}},"zh-Hans" : {"stringUnit" : {"state" : "translated",- "value" : "未选择:macOS为其自身服务保留此缓存,这些服务现在可能正在使用它。"+ "value" : "未选择:macOS为其自身服务保留此项,这些服务现在可能正在使用它。"}},"zh-Hant" : {"stringUnit" : {"state" : "translated",- "value" : "未選取:macOS為自己的服務保留此快取,這些服務現在可能正在使用它。"+ "value" : "未選取:macOS為自己的服務保留此項目,這些服務現在可能正在使用它。"}}}diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex e8bdd113..a85d1231 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -357,7 +357,7 @@ extension HoldBack {case .deletableSystemExtension:"a network extension macOS installed, which System Settings > General > Login Items & Extensions > Network Extensions deletes"case .signInPlugIn: "a plug-in macOS may load at login, left to its maker's uninstaller"- case .keptByMacOS: "a cache macOS keeps for itself"+ case .keptByMacOS: "macOS keeps it for its own services"case .openedFromMail: "an attachment opened from Mail, which may be the only copy"case .crashReport: "a crash report, which the app's developer may still ask for"case .inTheCloud: "syncs to your other devices through iCloud or another app, so moving it would remove it from them too"diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swiftindex c367dadc..07e5ecc9 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift@@ -118,7 +118,7 @@ public enum HoldBack: String, Sendable, Hashable {case deletableSystemExtension/// An authorization plug-in macOS may load at login (`SignInPlugIns`), left to its maker's uninstaller.case signInPlugIn- /// A cache macOS keeps for its own services, which may be using it at any moment (`SystemCaches`).+ /// What macOS keeps for its own services, which may be using it at any moment (`MacOSsOwnItems`).case keptByMacOS/// A copy Mail keeps of an attachment that was opened. One that was edited may exist nowhere else.case openedFromMaildiff --git a/Packages/PeelCore/Sources/PeelCore/Space/SystemCaches.swift b/Packages/PeelCore/Sources/PeelCore/Space/MacOSsOwnItems.swiftsimilarity index 50%rename from Packages/PeelCore/Sources/PeelCore/Space/SystemCaches.swiftrename to Packages/PeelCore/Sources/PeelCore/Space/MacOSsOwnItems.swiftindex b33310fe..a4914142 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/SystemCaches.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/MacOSsOwnItems.swift@@ -1,27 +1,28 @@import Foundationinternal import PeelPrivileged-/// The folders in a Caches folder that macOS keeps for its own services, which may be using them at any moment.-struct SystemCaches {- static func isMacOSs(_ name: String) -> Bool {- ProtectedData.isApplesName(name) || SystemFolders.keeps(name, in: .caches)- }-- private let cachesFolders: Set<String>+/// What macOS keeps for its own services in a Caches or a Logs folder, which those services may be using at any moment.+struct MacOSsOwnItems {+ private let folders: [String: SearchLocation.Kind]private let containerFolders: [[String]]init(environment: SearchEnvironment) {let locations = environment.locations- cachesFolders = Set(locations.filter { $0.kind == .caches }.map { PathPattern.comparablePath(of: $0.url) })+ folders = Dictionary(+ locations.filter { $0.kind == .caches || $0.kind == .logs }+ .map { (PathPattern.comparablePath(of: $0.url), $0.kind) },+ uniquingKeysWith: { first, _ in first }+ )containerFolders = locations.filter { $0.kind == .containers || $0.kind == .groupContainers }.map { PathComponents.of(PathPattern.comparablePath(of: $0.url)) }}- /// Whether macOS keeps `url` for itself: a folder in a Caches folder named for macOS, or anything in the container- /// of one of Apple's own apps.- func keeps(_ url: URL) -> Bool {- if cachesFolders.contains(PathPattern.comparablePath(of: url.deletingLastPathComponent())) {- return Self.isMacOSs(url.lastPathComponent)+ /// Whether macOS keeps `url` for itself: an item in a Caches or a Logs folder named as macOS names its own there,+ /// or anything in the container of one of Apple's own apps.+ func contains(_ url: URL) -> Bool {+ if let kind = folders[PathPattern.comparablePath(of: url.deletingLastPathComponent())] {+ let name = url.lastPathComponent+ return ProtectedData.isApplesName(name) || SystemFolders.keeps(name, in: kind)}return container(holding: url).map(ProtectedData.isApplesName) ?? false}diff --git a/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swift b/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swiftindex 5c2bad4c..aab62949 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swift@@ -81,7 +81,7 @@ public enum SpaceRemoval {measure: @escaping LeftoverScanner.Measure = LeftoverScanner.walk) async -> Plan {let children = children(of: item, environment: environment, exclusions: exclusions, running: running)- let systemCaches = SystemCaches(environment: environment)+ let macOSsOwn = MacOSsOwnItems(environment: environment)let reach = HelperReach(environment: environment)var sizes: [URL: Int64] = [:]var heldBack: [URL: HoldBack] = [:]@@ -95,7 +95,7 @@ public enum SpaceRemoval {if needsAnAdministrator { needsTheHelper.insert(child) }let beyond: HoldBack? = needsAnAdministrator && reach.isBeyond(child) ? .beyondTheHelper : nilheldBack[child] = beyond ?? item.heldBack- ?? (systemCaches.keeps(child) ? .keptByMacOS : HoldBack.seen(in: contents))+ ?? (macOSsOwn.contains(child) ? .keptByMacOS : HoldBack.seen(in: contents))?? (item.holdsBackRecentWrites && HoldBack.wasWrittenRecently(child, contents: contents)? .writtenRecently : nil)}@@ -162,7 +162,7 @@ public enum SpaceRemoval {var inUse: [(url: URL, name: String)] = []var leftToDeveloper: [URL] = []var refused: [URL: GuardRefusal] = [:]- let systemCaches = SystemCaches(environment: environment)+ let macOSsOwn = MacOSsOwnItems(environment: environment)let filesOnly = Set(item.onlyFilesIn.map(PathPattern.comparablePath))func sort(_ folder: URL, leaving owned: [[String]], owner: String?, onlyFiles inside: Bool = false) {let children = try? FileManager.default.contentsOfDirectory(at: folder, includingPropertiesForKeys: nil)@@ -211,7 +211,7 @@ public enum SpaceRemoval {)for url in item.urls {// Everything in an app's container is that app's, whatever its name.- let owner = systemCaches.container(holding: url).flatMap { running[Naming.normalized($0)] }+ let owner = macOSsOwn.container(holding: url).flatMap { running[Naming.normalized($0)] }sort(url, leaving: developerFolders.inside(url), owner: owner)}return (removable, inUse, leftToDeveloper, refused)diff --git a/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift b/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swiftindex 69cd1f20..b0a85b06 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift@@ -472,7 +472,8 @@ public enum SpaceInventory {/// Whether macOS keeps `name` for its own services in a folder every account shares.static func isMacOSsOwn(_ name: String) -> Bool {- SystemCaches.isMacOSs(name) || SystemFolders.keeps(name, in: .logs)+ ProtectedData.isApplesName(name) || SystemFolders.keeps(name, in: .caches)+ || SystemFolders.keeps(name, in: .logs)}private static func folders(in parent: URL) -> [URL] {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swiftindex 3cac2457..bf66c562 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swift@@ -132,12 +132,14 @@ struct SpaceRemovalTests {#expect(plan.leftToDeveloper.map(\.lastPathComponent) == ["Google"])}- @Test func neverSelectsACacheMacOSKeepsForItself() async throws {+ @Test func neverSelectsACacheOrALogMacOSKeepsForItself() async throws {let directory = try TemporaryDirectory()for name in ["com.apple.Spotlight", "familycircled", "GameStoreKit", "org.example.notes", "com.gone.app"] {try directory.file("home/Library/Caches/\(name)/data.db")}- try directory.file("home/Library/Logs/com.apple.example/run.log")+ for name in ["com.apple.example", "Assistant", "org.example.notes"] {+ try directory.file("home/Library/Logs/\(name)/run.log")+ }let logs = SpaceItem(id: "logs",category: .library,@@ -155,7 +157,9 @@ struct SpaceRemovalTests {#expect(names(Array(caches.suggested)) == ["com.gone.app", "org.example.notes"])let keptByMacOS = caches.heldBack.filter { $0.value == .keptByMacOS }.map(\.key)#expect(names(keptByMacOS) == ["GameStoreKit", "com.apple.Spotlight", "familycircled"])- #expect(names(Array(logged.suggested)) == ["com.apple.example"])+ #expect(names(Array(logged.suggested)) == ["org.example.notes"])+ let logsKept = logged.heldBack.filter { $0.value == .keptByMacOS }.map(\.key)+ #expect(names(logsKept) == ["Assistant", "com.apple.example"])}@Test func holdsBackACacheWrittenInTheLastMinutesInTheCacheAreasOnly() async throws {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/SystemCachesTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/SystemCachesTests.swiftdeleted file mode 100644index 0ea561bd..00000000--- a/Packages/PeelCore/Tests/PeelCoreTests/SystemCachesTests.swift+++ /dev/null@@ -1,13 +0,0 @@-import Foundation-@testable import PeelCore-import Testing--struct SystemCachesTests {- @Test func knowsApplesCachesByTheirNameOrTheSystemsOwn() {- #expect(SystemCaches.isMacOSs("com.apple.Spotlight"))- #expect(SystemCaches.isMacOSs("CloudKit"))- #expect(SystemCaches.isMacOSs("cloudkit"))- #expect(!SystemCaches.isMacOSs("pip"))- #expect(!SystemCaches.isMacOSs("org.example.app"))- }-}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/SystemFoldersTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/SystemFoldersTests.swiftindex c7c3e214..d5d3d9ac 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/SystemFoldersTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/SystemFoldersTests.swift@@ -23,6 +23,15 @@ struct SystemFoldersTests {}}+ @Test func knowsMacOSsOwnByTheirNameOrApplesWhateverTheirCase() {+ #expect(SpaceInventory.isMacOSsOwn("com.apple.Spotlight"))+ #expect(SpaceInventory.isMacOSsOwn("CloudKit"))+ #expect(SpaceInventory.isMacOSsOwn("cloudkit"))+ #expect(SpaceInventory.isMacOSsOwn("Assistant"))+ #expect(!SpaceInventory.isMacOSsOwn("pip"))+ #expect(!SpaceInventory.isMacOSsOwn("org.example.app"))+ }+@Test func aProcessKeepsItsCachesHTTPStorageAndTemporaryItemsUnderOneName() {#expect(SystemFolders.keeps("familycircled", in: .caches))#expect(SystemFolders.keeps("familycircled", in: .httpStorages))diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex 0cf7963f..3de80def 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -338,7 +338,7 @@ extension HoldBack {case .signInPlugIn:"Left alone: macOS may load this plug-in when someone logs in, and taking it away could keep anyone from logging in, so only its maker’s uninstaller removes it."case .keptByMacOS:- "Not selected: macOS keeps this cache for its own services, which may be using it right now."+ "Not selected: macOS keeps this for its own services, which may be using it right now."case .openedFromMail:"Not selected: Mail keeps a copy here of each attachment you open, and one you edited may exist nowhere else."case .crashReport:diff --git a/SAFETY.md b/SAFETY.mdindex 75f3717a..e789f239 100644--- a/SAFETY.md+++ b/SAFETY.md@@ -370,8 +370,8 @@ Never selected for you, even when found:Developer page lists only what one tool owns outright: never a toolchain or an installation, never a file thatholds an account or a token, and never a folder that keeps your own work beside a cache, such as an editor'sunsaved files or a chat history, only the cache inside it.-- A cache macOS keeps for its own services in `~/Library/Caches` (Spotlight's, the fonts') or in the container of one of- Apple's apps.+- A cache or a log macOS keeps for its own services in `~/Library/Caches` or `~/Library/Logs` (Spotlight's caches,+ Siri's logs) or in the container of one of Apple's apps.- A cache in `~/Library/Caches`, or in the folder macOS gives your account for caches, that something wrote to inthe last 15 minutes: Peel knows an open app's caches only by the app's names, and a program may still be usingone under a name of its own.