Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Space empties the caches apps keep for every account in /Library/Caches

Țugui Dragoșfc02f35f96c7
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 518abb8d..7bd4d847 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -16552,6 +16552,112 @@
},
"shouldTranslate" : false
},
+ "Caches for All Users" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Mezipaměti pro všechny uživatele"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Caches für alle Benutzer:innen"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Cachés para todos los usuarios"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Caches pour tous les utilisateurs"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Cache per tutti gli utenti"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "すべてのユーザのキャッシュ"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "모든 사용자의 캐시"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Caches voor alle gebruikers"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Pamięci podręczne dla wszystkich użytkowników"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Caches para Todos os Usuários"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Memorii tampon pentru toți utilizatorii"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Кэши для всех пользователей"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Cachar för alla användare"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Tüm Kullanıcılar İçin Önbellekler"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Кеші для всіх користувачів"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "所有用户的缓存"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "所有使用者的快取"
+ }
+ }
+ }
+ },
"Caches from developer tools will appear here." : {
"localizations" : {
"cs" : {
@@ -134833,6 +134939,112 @@
}
}
},
+ "What apps cached for every account on this Mac, in the Library at the top of the disk. What macOS keeps there for its own services isn’t listed, and what an open app uses stays. What an administrator owns goes through Peel’s helper." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Co aplikace uložily do mezipaměti pro všechny účty v tomto Macu, v Knihovně na nejvyšší úrovni disku. Co tam systém macOS uchovává pro vlastní služby, se nezobrazuje, a co používá otevřená aplikace, zůstává na místě. Co patří správci, se přesouvá přes pomocníka Peelu."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Was Apps für jeden Benutzeraccount auf diesem Mac zwischengespeichert haben, in der Library auf der obersten Ebene des Volumes. Was macOS dort für seine eigenen Dienste aufbewahrt, wird nicht angezeigt, und was eine geöffnete App verwendet, bleibt erhalten. Was einem Administrator gehört, wird über das Hilfsprogramm von Peel verschoben."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Lo que las apps han guardado en caché para todas las cuentas de este Mac, en la carpeta Biblioteca de la raíz del disco. Lo que macOS guarda ahí para sus propios servicios no se muestra, y lo que usa una app abierta se queda donde está. Lo que pertenece a un administrador se traslada mediante el asistente de Peel."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ce que les apps ont mis en cache pour tous les comptes de ce Mac, dans le dossier Bibliothèque à la racine du disque. Ce que macOS y conserve pour ses propres services n’est pas listé, et ce qu’une app ouverte utilise reste en place. Ce qui appartient à un administrateur passe par l’utilitaire de Peel."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ciò che le app hanno messo in cache per tutti gli account di questo Mac, nella cartella Libreria al livello principale del disco. Ciò che macOS conserva lì per i propri servizi non è elencato, e ciò che usa un’app aperta resta al suo posto. Ciò che appartiene a un amministratore viene spostato tramite l’assistente di Peel."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "アプリがこのMacのすべてのアカウントのためにキャッシュしたもので、ディスクの最上位にある“ライブラリ”フォルダにあります。macOSが自身のサービスのためにそこに保管しているものは一覧に表示されず、開いているアプリが使用しているものはそのまま残ります。管理者が所有するものは、Peelのヘルパーを通じてゴミ箱に入れます。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "앱이 디스크 최상위에 있는 라이브러리에 이 Mac의 모든 계정을 위해 캐시한 항목입니다. macOS가 자체 서비스를 위해 그곳에 보관하는 항목은 목록에 표시되지 않으며, 열려 있는 앱이 사용하는 항목은 그대로 유지됩니다. 관리자가 소유한 항목은 Peel 보조 프로그램을 통해 이동합니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Wat apps voor elke account op deze Mac in de cache hebben gezet, in de map 'Bibliotheek' bovenaan de schijf. Wat macOS daar voor zijn eigen diensten bewaart, wordt niet getoond, en wat een geopende app gebruikt, blijft staan. Wat van een beheerder is, gaat via het hulpprogramma van Peel."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "To, co aplikacje zapisały w pamięci podręcznej dla wszystkich kont na tym Macu, w folderze Biblioteki na najwyższym poziomie dysku. Tego, co macOS przechowuje tam na potrzeby własnych usług, nie ma na liście, a to, czego używa otwarta aplikacja, zostaje na miejscu. To, co należy do administratora, przenosi pomocnik Peel."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O que os apps guardaram em cache para todas as contas deste Mac, na Biblioteca que fica no nível superior do disco. O que o macOS mantém ali para os próprios serviços não é listado, e o que um app aberto usa permanece. O que pertence a um administrador passa pelo auxiliar do Peel."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Tot ce au păstrat aplicațiile în memoria tampon pentru toate conturile de pe acest Mac, în dosarul Bibliotecă de la rădăcina discului. Ce păstrează macOS acolo pentru propriile servicii nu este listat, iar ce folosește o aplicație deschisă rămâne pe loc. Ce deține un administrator este mutat prin instrumentul de ajutor Peel."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Все, что приложения кэшировали для всех учетных записей на этом Mac, в папке «Библиотека» в корне диска. То, что macOS хранит там для своих служб, не показывается, а то, что использует открытое приложение, остается на месте. То, чем владеет администратор, перемещается через помощника Peel."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Det som appar har cachat för alla konton på den här datorn, i mappen Bibliotek på skivans översta nivå. Det som macOS sparar där för sina egna tjänster visas inte, och det som en öppen app använder stannar kvar. Det som en administratör äger går via Peels hjälpprogram."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Uygulamaların bu Mac’teki her hesap için, diskin en üstündeki Kitaplık klasöründe önbelleğe aldıkları. macOS’in orada kendi hizmetleri için tuttukları listelenmez ve açık bir uygulamanın kullandıkları yerinde kalır. Bir yöneticinin sahip oldukları Peel’in yardımcısı aracılığıyla taşınır."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Те, що програми кешували для всіх облікових записів на цьому Mac, у Бібліотеці на верхньому рівні диска. Те, що macOS зберігає там для власних служб, не показується, а те, чим користується відкрита програма, лишається. Те, що належить адміністратору, переміщується через помічника Peel."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "App在磁盘顶层的资源库中为这台Mac上的所有账户缓存的内容。macOS为其自身服务保留在那里的内容不会列出,已打开的App正在使用的内容会保留。管理员拥有的内容会通过Peel的帮助程序移除。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "App為這部Mac上的所有帳號儲存的快取,位於磁碟最上層的「資源庫」中。macOS為其自身服務保留在那裡的內容不會列出,打開中的App正在使用的內容會保留。管理者擁有的項目會透過Peel的輔助程式移動。"
+ }
+ }
+ }
+ },
"What could be moved went to the Trash. History can put it back until the app writes new files in its place." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swift b/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swift
index 74977431..5897b865 100644
--- a/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Space/SpaceRemoval.swift
@@ -19,6 +19,8 @@ public enum SpaceRemoval {
/// Why a removable item is left for the person to choose, from what measuring it saw. One missing here holds
/// nothing that keeps it from being selected.
public var heldBack: [URL: HoldBack] = [:]
+ /// The removable items only an administrator can move, which go through the helper.
+ public var needsTheHelper: Set<URL> = []
/// The open apps whose folders are left alone, each named once and sorted, by the names the user knows, not
/// the folder names. One app can write to several folders, by its name and by its identifier.
@@ -53,16 +55,22 @@ public enum SpaceRemoval {
) async -> Plan {
let children = children(of: item, environment: environment, exclusions: exclusions, running: running)
let systemCaches = SystemCaches(environment: environment)
+ let reach = HelperReach(environment: environment)
var sizes: [URL: Int64] = [:]
var heldBack: [URL: HoldBack] = [:]
+ var needsTheHelper: Set<URL> = []
for child in children.removable where !Task.isCancelled {
let contents = await measure(child)
sizes[child] = contents.flatMap { $0.couldNotBeRead ? nil : $0.size }
- heldBack[child] = item.heldBack ?? (systemCaches.keeps(child) ? .keptByMacOS : HoldBack.seen(in: contents))
+ let needsAnAdministrator = FileAccess.requiresPrivilegesToRemove(child)
+ if needsAnAdministrator { needsTheHelper.insert(child) }
+ let beyond: HoldBack? = needsAnAdministrator && reach.isBeyond(child) ? .beyondTheHelper : nil
+ heldBack[child] = beyond ?? item.heldBack
+ ?? (systemCaches.keeps(child) ? .keptByMacOS : HoldBack.seen(in: contents))
}
return Plan(
removable: children.removable, inUse: children.inUse, leftToDeveloper: children.leftToDeveloper, sizes: sizes,
- heldBack: heldBack
+ heldBack: heldBack, needsTheHelper: needsTheHelper
)
}
@@ -105,6 +113,7 @@ public enum SpaceRemoval {
let children = try? FileManager.default.contentsOfDirectory(at: folder, includingPropertiesForKeys: nil)
for child in children ?? [] {
let name = child.lastPathComponent
+ if item.leavesMacOSsOwn, SystemCaches.isMacOSs(name) { continue }
let app = owner ?? running[Naming.normalized(name)]
let listed = owned.filter { fnmatch($0[0], name, FNM_CASEFOLD) == 0 }
if app == nil, !listed.isEmpty, !listed.contains(where: { $0.count == 1 }), child.isRealFolder {
diff --git a/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift b/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift
index cc8511c3..e43ae2ab 100644
--- a/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift
@@ -28,6 +28,9 @@ public struct SpaceItem: Sendable, Hashable, Identifiable {
public let handling: Handling
/// Why nothing in this area is selected for the person, whatever each item holds.
public var heldBack: HoldBack?
+ /// True when what macOS keeps in its folders for its own services is neither measured nor offered: they run as
+ /// other accounts, whose open files Peel cannot see.
+ public var leavesMacOSsOwn = false
public var isReadOnly: Bool {
if case .readOnly = handling { true } else { false }
@@ -62,6 +65,7 @@ public enum SpaceInventory {
/// to this area too.
var groupContainerFolder: String?
var heldBack: HoldBack?
+ var leavesMacOSsOwn = false
/// Each of `paths` on this Mac: one that starts with `/` is under `root`, the rest are in `home`.
func urls(home: URL, root: URL) -> [URL] {
@@ -239,6 +243,13 @@ public enum SpaceInventory {
handling: .trash,
heldBack: .sharedWithEveryone
),
+ Definition(
+ id: "system-caches",
+ category: .library,
+ paths: ["/Library/Caches"],
+ handling: .trash,
+ leavesMacOSsOwn: true
+ ),
]
/// The total size of `urls`, or nil when any of them could not be measured. A folder a file provider owns
@@ -271,6 +282,11 @@ public enum SpaceInventory {
.filter { !ProtectedData.isApplesName($0.lastPathComponent) }
}
+ private static func childrenNotMacOSs(of folder: URL) -> [URL] {
+ let names = (try? FileManager.default.contentsOfDirectory(atPath: folder.path(percentEncoded: false))) ?? []
+ return names.filter { !SystemCaches.isMacOSs($0) }.map { folder.appending(path: $0) }
+ }
+
private static func folders(in parent: URL) -> [URL] {
let names = (try? FileManager.default.contentsOfDirectory(atPath: parent.path(percentEncoded: false))) ?? []
return names.sorted().map { parent.appending(path: $0, directoryHint: .isDirectory) }.filter(\.isRealFolder)
@@ -314,7 +330,8 @@ public enum SpaceInventory {
var pending = wanted.makeIterator()
func addNext() -> Bool {
guard !Task.isCancelled, let (definition, urls) = pending.next() else { return false }
- group.addTask { (definition, urls, await size(of: urls, measure: measure)) }
+ let measured = definition.leavesMacOSsOwn ? urls.flatMap(childrenNotMacOSs) : urls
+ group.addTask { (definition, urls, await size(of: measured, measure: measure)) }
return true
}
for _ in 0..<4 where addNext() {}
@@ -327,7 +344,8 @@ public enum SpaceInventory {
urls: urls,
size: size,
handling: definition.handling,
- heldBack: definition.heldBack
+ heldBack: definition.heldBack,
+ leavesMacOSsOwn: definition.leavesMacOSsOwn
))
}
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Space/SystemCaches.swift b/Packages/PeelCore/Sources/PeelCore/Space/SystemCaches.swift
index c580c966..6ec65802 100644
--- a/Packages/PeelCore/Sources/PeelCore/Space/SystemCaches.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Space/SystemCaches.swift
@@ -8,7 +8,9 @@ struct SystemCaches {
"AMSDataMigratorTool": "/System/Library/PrivateFrameworks/AppleMediaServices.framework"
+ "/Versions/A/Resources/AMSDataMigratorTool",
"CloudKit": "/System/Library/Frameworks/CloudKit.framework",
+ "ColorSync": "/System/Library/ColorSync",
"containermanagerd": "/usr/libexec/containermanagerd",
+ "Desktop Pictures": "/System/Library/Desktop Pictures",
"FamilyCircle": "/System/Library/PrivateFrameworks/FamilyCircle.framework",
"familycircled": "/System/Library/PrivateFrameworks/FamilyCircle.framework/Versions/A/Resources/familycircled",
"GameKit": "/System/Library/Frameworks/GameKit.framework",
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swift
index 35a640e1..7dd6134d 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swift
@@ -40,7 +40,8 @@ struct SpaceInventoryTests {
try directory.file("Library/Logs/big.log", bytes: 400_000)
try directory.file("Library/Caches/com.example.app/blob", bytes: 400_000)
- let report = await SpaceInventory.scan(home: directory.url, root: directory.url, minimumSize: 100_000) { url in
+ let root = directory.url.appending(path: "root", directoryHint: .isDirectory)
+ let report = await SpaceInventory.scan(home: directory.url, root: root, minimumSize: 100_000) { url in
url.lastPathComponent == "Caches" ? nil : await FileSize.reclaimableSize(of: url, within: FileSize.budget)
}
@@ -172,6 +173,27 @@ struct SpaceInventoryTests {
#expect(cache.heldBack == .sharedWithEveryone)
}
+ /// The caches apps keep for every account are measured without what macOS keeps there for its own services,
+ /// which belong to other accounts' processes and are never offered.
+ @Test func findsTheCachesAppsKeepForEveryAccountWithoutMacOSsOwn() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("root/Library/Caches/org.example.updater/package.bin", bytes: 8_000)
+ try directory.file("root/Library/Caches/com.apple.iconservices.store/icons.bin", bytes: 50_000)
+ try directory.file("root/Library/Caches/ColorSync/profiles.bin", bytes: 50_000)
+
+ let report = await SpaceInventory.scan(
+ home: directory.url.appending(path: "home", directoryHint: .isDirectory),
+ root: directory.url.appending(path: "root", directoryHint: .isDirectory),
+ minimumSize: 1, measure: FileSize.measure
+ )
+
+ let caches = try #require(report.items.first { $0.id == "system-caches" })
+ #expect(caches.urls.map { $0.pathComponents.suffix(2).joined(separator: "/") } == ["Library/Caches"])
+ #expect(caches.handling == .trash)
+ #expect(caches.leavesMacOSsOwn)
+ #expect(caches.size.map { $0 >= 8_000 && $0 < 50_000 } == true)
+ }
+
@Test func everyDefinitionSaysWhatItIsAndWhoOwnsIt() {
for definition in SpaceInventory.definitions {
#expect(!definition.id.isEmpty)
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swift
index 3a53ac58..081efdff 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swift
@@ -119,6 +119,49 @@ struct SpaceRemovalTests {
#expect(names(Array(logged.suggested)) == ["com.apple.example"])
}
+ /// In the caches every account shares, what macOS keeps is left out of the plan altogether: its services run
+ /// as other accounts, whose open files Peel cannot see. What only an administrator can move goes through the
+ /// helper.
+ @Test func leavesMacOSsOwnOutOfTheCachesEveryAccountShares() async throws {
+ let directory = try TemporaryDirectory()
+ for name in ["com.apple.iconservices.store", "ColorSync", "Desktop Pictures", "org.example.updater"] {
+ try directory.file("root/Library/Caches/\(name)/data.bin")
+ }
+ let shared = SpaceItem(
+ id: "system-caches",
+ category: .library,
+ urls: [directory.url.appending(path: "root/Library/Caches", directoryHint: .isDirectory)],
+ size: 0,
+ handling: .trash,
+ leavesMacOSsOwn: true
+ )
+
+ let plan = await SpaceRemoval.plan(for: shared, environment: environment(directory), running: [:])
+
+ #expect(plan.removable.map(\.lastPathComponent) == ["org.example.updater"])
+ #expect(plan.needsTheHelper.isEmpty, "a folder the person owns moves without the helper")
+ }
+
+ @Test(.permissionsHold) func whatOnlyAnAdministratorCanMoveGoesThroughTheHelper() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("root/Library/Caches/org.example.updater/data.bin")
+ try directory.setPermissions(0o555, of: "root/Library/Caches")
+ defer { try? directory.setPermissions(0o755, of: "root/Library/Caches") }
+ let shared = SpaceItem(
+ id: "system-caches",
+ category: .library,
+ urls: [directory.url.appending(path: "root/Library/Caches", directoryHint: .isDirectory)],
+ size: 0,
+ handling: .trash,
+ leavesMacOSsOwn: true
+ )
+
+ let plan = await SpaceRemoval.plan(for: shared, environment: environment(directory), running: [:])
+
+ #expect(plan.needsTheHelper.map(\.lastPathComponent) == ["org.example.updater"])
+ #expect(plan.heldBack.isEmpty, "the helper serves the caches every account shares")
+ }
+
@Test func emptiesAContainersCachesUnlessItsAppIsOpenOrApples() async throws {
let directory = try TemporaryDirectory()
let containers = "home/Library/Containers"
diff --git a/Peel/Model/SpaceLibrary.swift b/Peel/Model/SpaceLibrary.swift
index b9330d1c..f395f48c 100644
--- a/Peel/Model/SpaceLibrary.swift
+++ b/Peel/Model/SpaceLibrary.swift
@@ -40,7 +40,7 @@ final class SpaceLibrary: RowSelection {
let previous = plans[item.id]
let chosen = choices[item.id, default: KeptSelection()].update(
selectedURLs,
- selectable: Set(plan.removable),
+ selectable: Set(plan.removable.filter { plan.heldBack[$0]?.cannotBeMoved != true }),
suggested: plan.suggested
)
selectedURLs.subtract(previous?.removable ?? [])
@@ -96,8 +96,9 @@ extension SpaceLibrary: CarriesSelection {
defer { isRemoving = false }
let exclusions = ExclusionsStore.shared.exclusions
let removable = await SpaceRemoval.removable(in: item, exclusions: exclusions, running: RunningCopies.current)
+ .filter { selectedURLs.contains($0) && part.sizes.keys.contains($0) }
return await TrashService(exclusions: exclusions)
- .trash(removable.filter { selectedURLs.contains($0) && part.sizes.keys.contains($0) })
+ .trash(removable, usingHelperFor: Set(removable.filter(FileAccess.requiresPrivilegesToRemove)))
}
func refresh(after parts: [CarriedSelection.Part], apps: AppLibrary) async {
diff --git a/Peel/Views/Space/SpaceDetailView.swift b/Peel/Views/Space/SpaceDetailView.swift
index ddee36eb..e6864247 100644
--- a/Peel/Views/Space/SpaceDetailView.swift
+++ b/Peel/Views/Space/SpaceDetailView.swift
@@ -4,6 +4,7 @@ import SwiftUI
struct SpaceDetailView: View {
@Environment(SpaceLibrary.self) private var space
+ @Environment(HelperModel.self) private var helper
let item: SpaceItem
private var plan: SpaceRemoval.Plan? {
@@ -20,6 +21,9 @@ struct SpaceDetailView: View {
header
.listRowSeparator(.hidden)
RemovalsHeldBanner()
+ if let plan, plan.removable.contains(where: { isLocked($0, in: plan) }) {
+ HelperRequiredBanner()
+ }
Section {
Text(item.words.detail)
@@ -104,6 +108,8 @@ struct SpaceDetailView: View {
warning: plan.heldBack[url].map { String(localized: $0.explanation) },
size: plan.sizes[url] ?? 0,
isMeasured: plan.sizes[url] != nil,
+ isLocked: isLocked(url, in: plan),
+ isLeftAlone: plan.heldBack[url]?.cannotBeMoved == true,
isFirst: index == 0,
hasNoteColumn: !plan.heldBack.isEmpty,
selection: space, isSelected: space.isSelected(url)
@@ -114,7 +120,10 @@ struct SpaceDetailView: View {
SectionHeaderLine {
heading("Inside", "What is selected goes to the Trash, and History can put it back. The folders it sits in stay, since macOS expects to find them.")
} actions: {
- SelectAllButton(selectable: rows.filter { plan.heldBack[$0] == nil }, selection: Bindable(space).selectedURLs)
+ SelectAllButton(
+ selectable: rows.filter { plan.heldBack[$0] == nil && !isLocked($0, in: plan) },
+ selection: Bindable(space).selectedURLs
+ )
}
} footer: {
if !plan.appsToQuit.isEmpty || !plan.leftToDeveloper.isEmpty {
@@ -163,6 +172,12 @@ struct SpaceDetailView: View {
return plan == nil ? Text("in here") : Text("to remove")
}
+ /// True for an item only an administrator can move while the helper cannot act. One the helper would refuse
+ /// anyway is left alone rather than locked.
+ private func isLocked(_ url: URL, in plan: SpaceRemoval.Plan) -> Bool {
+ plan.needsTheHelper.contains(url) && plan.heldBack[url]?.cannotBeMoved != true && !helper.canAct
+ }
+
private static func ordered(_ plan: SpaceRemoval.Plan) -> [URL] {
plan.removable.sorted { first, second in
SizeTotal([plan.sizes[second]]) < SizeTotal([plan.sizes[first]])
diff --git a/Peel/Views/Space/SpaceText.swift b/Peel/Views/Space/SpaceText.swift
index 87dde58a..87016189 100644
--- a/Peel/Views/Space/SpaceText.swift
+++ b/Peel/Views/Space/SpaceText.swift
@@ -145,6 +145,10 @@ extension SpaceItem {
title: "Mail Downloads",
detail: "Copies of the attachments you opened in Mail. Mail deletes each with its message unless you edited it, so they are listed and never selected."
),
+ "system-caches": Words(
+ title: "Caches for All Users",
+ detail: "What apps cached for every account on this Mac, in the Library at the top of the disk. What macOS keeps there for its own services isn’t listed, and what an open app uses stays. What an administrator owns goes through Peel’s helper."
+ ),
"battlenet-cache": Words(
title: "Battle.net Cache",
detail: "What the Battle.net app caches for every account on this Mac. Blizzard says removing it doesn’t affect your games, and the app makes it again. Since it belongs to every account, it is listed and never selected."
diff --git a/README.md b/README.md
index e2a3e2f3..6fa95757 100644
--- a/README.md
+++ b/README.md
@@ -119,7 +119,8 @@ Peel is free and open source, and it speaks English and 17 other languages.
iPhone backups hold. Nothing is selected for you.
- **iCloud Drive:** files already safe in iCloud that are also downloaded to this Mac. Remove Downloads, as in
Finder, takes away only the copy on this Mac: each file stays in iCloud and downloads again when you open it.
-- **Space:** what's taking up room, and which app it belongs to.
+- **Space:** what's taking up room, and which app it belongs to. The caches apps keep for every account, in the
+ Library at the top of the disk, go through Peel's helper, and what macOS keeps there is never listed.
- **File Search:** large or old files, found through Spotlight.
What you select on these pages, iCloud Drive aside, stays selected while you look at the others, and Move to Trash
diff --git a/SAFETY.md b/SAFETY.md
index 94957049..6bf0e826 100644
--- a/SAFETY.md
+++ b/SAFETY.md
@@ -119,7 +119,8 @@ the Trash: Peel never does that for you.
Right before anything moves, Peel looks at the files other programs of yours hold open, and leaves where it is any
file or folder with one of them inside, naming the program: moving a database or a cache from under an agent, a
daemon, or a server that is using it would break it. Programs that run as another account or as root, macOS's own
-among them, cannot be seen this way, which is why Space also leaves macOS's own caches unselected.
+among them, cannot be seen this way, which is why Space also leaves macOS's own caches unselected, and in the
+Library at the top of the disk, where those programs keep theirs, does not list them at all.
A move to the Trash, or back from it, never replaces what is already at the new name. Most disks refuse that by
themselves; on one that cannot, such as exFAT, Peel first takes the name with an empty placeholder, which only a