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.

Never move what iCloud and File Provider keep to stay in sync

Țugui Dragoșfe18e05b6970
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index cd8d757c..a0ecd1cf 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -107962,7 +107962,7 @@
}
}
},
- "Peel leaves ^[%lld folder](inflect: true) here alone because it protects what is there, such as a wallet, an app’s documents, or a library." : {
+ "Peel leaves ^[%lld folder](inflect: true) here alone because it protects what is there, such as what iCloud keeps to stay in sync, a wallet, an app’s documents, or a library." : {
"localizations" : {
"cs" : {
"variations" : {
@@ -107970,25 +107970,25 @@
"few" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel zde %lld složky ponechává nedotčené, protože chrání, co v nich je, například peněženku, dokumenty aplikace nebo knihovnu."
+ "value" : "Peel zde %lld složky ponechává nedotčené, protože chrání, co v nich je, například to, co iCloud uchovává pro synchronizaci, peněženku, dokumenty aplikace nebo knihovnu."
}
},
"many" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel zde %lld složky ponechává nedotčené, protože chrání, co v nich je, například peněženku, dokumenty aplikace nebo knihovnu."
+ "value" : "Peel zde %lld složky ponechává nedotčené, protože chrání, co v nich je, například to, co iCloud uchovává pro synchronizaci, peněženku, dokumenty aplikace nebo knihovnu."
}
},
"one" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel zde %lld složku ponechává nedotčenou, protože chrání, co v ní je, například peněženku, dokumenty aplikace nebo knihovnu."
+ "value" : "Peel zde %lld složku ponechává nedotčenou, protože chrání, co v ní je, například to, co iCloud uchovává pro synchronizaci, peněženku, dokumenty aplikace nebo knihovnu."
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel zde %lld složek ponechává nedotčených, protože chrání, co v nich je, například peněženku, dokumenty aplikace nebo knihovnu."
+ "value" : "Peel zde %lld složek ponechává nedotčených, protože chrání, co v nich je, například to, co iCloud uchovává pro synchronizaci, peněženku, dokumenty aplikace nebo knihovnu."
}
}
}
@@ -108000,13 +108000,13 @@
"one" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel lässt %lld Ordner hier unangetastet, weil Peel schützt, was darin liegt, etwa eine Wallet, die Dokumente einer App oder eine Mediathek."
+ "value" : "Peel lässt %lld Ordner hier unangetastet, weil Peel schützt, was darin liegt, etwa das, was iCloud zum Synchronisieren aufbewahrt, eine Wallet, die Dokumente einer App oder eine Mediathek."
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel lässt %lld Ordner hier unangetastet, weil Peel schützt, was darin liegt, etwa eine Wallet, die Dokumente einer App oder eine Mediathek."
+ "value" : "Peel lässt %lld Ordner hier unangetastet, weil Peel schützt, was darin liegt, etwa das, was iCloud zum Synchronisieren aufbewahrt, eine Wallet, die Dokumente einer App oder eine Mediathek."
}
}
}
@@ -108018,19 +108018,19 @@
"many" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel deja %lld de carpetas de aquí sin tocar porque protege lo que hay dentro, como un monedero digital, los documentos de una app o una biblioteca."
+ "value" : "Peel deja %lld de carpetas de aquí sin tocar porque protege lo que hay dentro, como lo que iCloud guarda para mantenerse sincronizado, un monedero digital, los documentos de una app o una biblioteca."
}
},
"one" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel deja una carpeta de aquí sin tocar porque protege lo que hay dentro, como un monedero digital, los documentos de una app o una biblioteca."
+ "value" : "Peel deja una carpeta de aquí sin tocar porque protege lo que hay dentro, como lo que iCloud guarda para mantenerse sincronizado, un monedero digital, los documentos de una app o una biblioteca."
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel deja %lld carpetas de aquí sin tocar porque protege lo que hay dentro, como un monedero digital, los documentos de una app o una biblioteca."
+ "value" : "Peel deja %lld carpetas de aquí sin tocar porque protege lo que hay dentro, como lo que iCloud guarda para mantenerse sincronizado, un monedero digital, los documentos de una app o una biblioteca."
}
}
}
@@ -108042,19 +108042,19 @@
"many" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Ici, Peel laisse %lld de dossiers en place, car il protège ce qui s’y trouve, comme un portefeuille, les documents d’une app ou une bibliothèque."
+ "value" : "Ici, Peel laisse %lld de dossiers en place, car il protège ce qui s’y trouve, comme ce qu’iCloud conserve pour rester synchronisé, un portefeuille, les documents d’une app ou une bibliothèque."
}
},
"one" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Ici, Peel laisse %lld dossier en place, car il protège ce qui s’y trouve, comme un portefeuille, les documents d’une app ou une bibliothèque."
+ "value" : "Ici, Peel laisse %lld dossier en place, car il protège ce qui s’y trouve, comme ce qu’iCloud conserve pour rester synchronisé, un portefeuille, les documents d’une app ou une bibliothèque."
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Ici, Peel laisse %lld dossiers en place, car il protège ce qui s’y trouve, comme un portefeuille, les documents d’une app ou une bibliothèque."
+ "value" : "Ici, Peel laisse %lld dossiers en place, car il protège ce qui s’y trouve, comme ce qu’iCloud conserve pour rester synchronisé, un portefeuille, les documents d’une app ou une bibliothèque."
}
}
}
@@ -108066,19 +108066,19 @@
"many" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel lascia dove sono %lld di queste cartelle, perché protegge ciò che contengono, come un wallet, i documenti di un’app o una libreria."
+ "value" : "Peel lascia dove sono %lld di queste cartelle, perché protegge ciò che contengono, come i dati che iCloud conserva per la sincronizzazione, un wallet, i documenti di un’app o una libreria."
}
},
"one" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel lascia dov’è una di queste cartelle, perché protegge ciò che contiene, come un wallet, i documenti di un’app o una libreria."
+ "value" : "Peel lascia dov’è una di queste cartelle, perché protegge ciò che contiene, come i dati che iCloud conserva per la sincronizzazione, un wallet, i documenti di un’app o una libreria."
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel lascia dove sono %lld di queste cartelle, perché protegge ciò che contengono, come un wallet, i documenti di un’app o una libreria."
+ "value" : "Peel lascia dove sono %lld di queste cartelle, perché protegge ciò che contengono, come i dati che iCloud conserva per la sincronizzazione, un wallet, i documenti di un’app o una libreria."
}
}
}
@@ -108087,13 +108087,13 @@
"ja" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peelは、ここにある%lld個のフォルダをそのままにしています。ウォレット、アプリの書類、ライブラリなど、Peelが保護しているものが中にあるためです。"
+ "value" : "Peelは、ここにある%lld個のフォルダをそのままにしています。iCloudが同期のために保管しているデータ、ウォレット、アプリの書類、ライブラリなど、Peelが保護しているものが中にあるためです。"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel은 여기에 있는 폴더 %lld개를 그대로 둡니다. 지갑, 앱의 문서 또는 보관함처럼 그곳에 있는 항목을 Peel이 보호하기 때문입니다."
+ "value" : "Peel은 여기에 있는 폴더 %lld개를 그대로 둡니다. iCloud가 동기화된 상태를 유지하기 위해 보관하는 데이터, 지갑, 앱의 문서 또는 보관함처럼 그곳에 있는 항목을 Peel이 보호하기 때문입니다."
}
},
"nl" : {
@@ -108102,13 +108102,13 @@
"one" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel laat één map hier met rust, omdat het beschermt wat erin zit, zoals een wallet, de documenten van een app of een bibliotheek."
+ "value" : "Peel laat één map hier met rust, omdat het beschermt wat erin zit, zoals wat iCloud bewaart om synchroon te blijven, een wallet, de documenten van een app of een bibliotheek."
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel laat %lld mappen hier met rust, omdat het beschermt wat erin zit, zoals een wallet, de documenten van een app of een bibliotheek."
+ "value" : "Peel laat %lld mappen hier met rust, omdat het beschermt wat erin zit, zoals wat iCloud bewaart om synchroon te blijven, een wallet, de documenten van een app of een bibliotheek."
}
}
}
@@ -108120,25 +108120,25 @@
"few" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel zostawia %lld foldery z tego miejsca nietknięte, ponieważ chroni to, co jest w środku, na przykład portfel, dokumenty aplikacji lub bibliotekę."
+ "value" : "Peel zostawia %lld foldery z tego miejsca nietknięte, ponieważ chroni to, co jest w środku, na przykład dane synchronizacji iCloud, portfel, dokumenty aplikacji lub bibliotekę."
}
},
"many" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel zostawia %lld folderów z tego miejsca nietkniętych, ponieważ chroni to, co jest w środku, na przykład portfel, dokumenty aplikacji lub bibliotekę."
+ "value" : "Peel zostawia %lld folderów z tego miejsca nietkniętych, ponieważ chroni to, co jest w środku, na przykład dane synchronizacji iCloud, portfel, dokumenty aplikacji lub bibliotekę."
}
},
"one" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel zostawia %lld folder z tego miejsca nietknięty, ponieważ chroni to, co jest w środku, na przykład portfel, dokumenty aplikacji lub bibliotekę."
+ "value" : "Peel zostawia %lld folder z tego miejsca nietknięty, ponieważ chroni to, co jest w środku, na przykład dane synchronizacji iCloud, portfel, dokumenty aplikacji lub bibliotekę."
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel zostawia %lld folderu z tego miejsca nietkniętego, ponieważ chroni to, co jest w środku, na przykład portfel, dokumenty aplikacji lub bibliotekę."
+ "value" : "Peel zostawia %lld folderu z tego miejsca nietkniętego, ponieważ chroni to, co jest w środku, na przykład dane synchronizacji iCloud, portfel, dokumenty aplikacji lub bibliotekę."
}
}
}
@@ -108150,19 +108150,19 @@
"many" : {
"stringUnit" : {
"state" : "translated",
- "value" : "O Peel deixa %lld de pastas daqui intocadas porque protege o que há nelas, como uma carteira, os documentos de um app ou uma biblioteca."
+ "value" : "O Peel deixa %lld de pastas daqui intocadas porque protege o que há nelas, como aquilo que o iCloud guarda para se manter sincronizado, uma carteira, os documentos de um app ou uma biblioteca."
}
},
"one" : {
"stringUnit" : {
"state" : "translated",
- "value" : "O Peel deixa %lld pasta daqui intocada porque protege o que há nela, como uma carteira, os documentos de um app ou uma biblioteca."
+ "value" : "O Peel deixa %lld pasta daqui intocada porque protege o que há nela, como aquilo que o iCloud guarda para se manter sincronizado, uma carteira, os documentos de um app ou uma biblioteca."
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
- "value" : "O Peel deixa %lld pastas daqui intocadas porque protege o que há nelas, como uma carteira, os documentos de um app ou uma biblioteca."
+ "value" : "O Peel deixa %lld pastas daqui intocadas porque protege o que há nelas, como aquilo que o iCloud guarda para se manter sincronizado, uma carteira, os documentos de um app ou uma biblioteca."
}
}
}
@@ -108174,19 +108174,19 @@
"few" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel lasă %lld dosare de aici neatinse, deoarece protejează ce se află acolo, cum ar fi un portofel, documentele unei aplicații sau o bibliotecă."
+ "value" : "Peel lasă %lld dosare de aici neatinse, deoarece protejează ce se află acolo, cum ar fi ceea ce păstrează iCloud pentru a rămâne sincronizat, un portofel, documentele unei aplicații sau o bibliotecă."
}
},
"one" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel lasă %lld dosar de aici neatins, deoarece protejează ce se află acolo, cum ar fi un portofel, documentele unei aplicații sau o bibliotecă."
+ "value" : "Peel lasă %lld dosar de aici neatins, deoarece protejează ce se află acolo, cum ar fi ceea ce păstrează iCloud pentru a rămâne sincronizat, un portofel, documentele unei aplicații sau o bibliotecă."
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel lasă %lld de dosare de aici neatinse, deoarece protejează ce se află acolo, cum ar fi un portofel, documentele unei aplicații sau o bibliotecă."
+ "value" : "Peel lasă %lld de dosare de aici neatinse, deoarece protejează ce se află acolo, cum ar fi ceea ce păstrează iCloud pentru a rămâne sincronizat, un portofel, documentele unei aplicații sau o bibliotecă."
}
}
}
@@ -108198,25 +108198,25 @@
"few" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel оставляет здесь на месте %lld папки, потому что защищает то, что там находится, например кошелек, документы приложения или медиатеку."
+ "value" : "Peel оставляет здесь на месте %lld папки, потому что защищает то, что там находится, например данные, которые iCloud хранит для синхронизации, кошелек, документы приложения или медиатеку."
}
},
"many" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel оставляет здесь на месте %lld папок, потому что защищает то, что там находится, например кошелек, документы приложения или медиатеку."
+ "value" : "Peel оставляет здесь на месте %lld папок, потому что защищает то, что там находится, например данные, которые iCloud хранит для синхронизации, кошелек, документы приложения или медиатеку."
}
},
"one" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel оставляет здесь на месте %lld папку, потому что защищает то, что там находится, например кошелек, документы приложения или медиатеку."
+ "value" : "Peel оставляет здесь на месте %lld папку, потому что защищает то, что там находится, например данные, которые iCloud хранит для синхронизации, кошелек, документы приложения или медиатеку."
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel оставляет здесь на месте %lld папки, потому что защищает то, что там находится, например кошелек, документы приложения или медиатеку."
+ "value" : "Peel оставляет здесь на месте %lld папки, потому что защищает то, что там находится, например данные, которые iCloud хранит для синхронизации, кошелек, документы приложения или медиатеку."
}
}
}
@@ -108228,13 +108228,13 @@
"one" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel lämnar %lld mapp här orörd eftersom Peel skyddar det som ligger i den, till exempel en plånbok, en apps dokument eller ett bibliotek."
+ "value" : "Peel lämnar %lld mapp här orörd eftersom Peel skyddar det som ligger i den, till exempel det som iCloud sparar för att hålla allt synkroniserat, en plånbok, en apps dokument eller ett bibliotek."
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel lämnar %lld mappar här orörda eftersom Peel skyddar det som ligger i dem, till exempel en plånbok, en apps dokument eller ett bibliotek."
+ "value" : "Peel lämnar %lld mappar här orörda eftersom Peel skyddar det som ligger i dem, till exempel det som iCloud sparar för att hålla allt synkroniserat, en plånbok, en apps dokument eller ett bibliotek."
}
}
}
@@ -108246,13 +108246,13 @@
"one" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel buradaki %lld klasörü yerinde bırakır, çünkü içindekileri korur: örneğin bir cüzdan, bir uygulamanın belgeleri veya bir fotoğraf, müzik ya da video arşivi."
+ "value" : "Peel buradaki %lld klasörü yerinde bırakır, çünkü içindekileri korur: örneğin iCloud’un eşzamanlı kalmak için tuttukları, bir cüzdan, bir uygulamanın belgeleri veya bir fotoğraf, müzik ya da video arşivi."
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel buradaki %lld klasörü yerinde bırakır, çünkü bu klasörlerin içindekileri korur: örneğin bir cüzdan, bir uygulamanın belgeleri veya bir fotoğraf, müzik ya da video arşivi."
+ "value" : "Peel buradaki %lld klasörü yerinde bırakır, çünkü bu klasörlerin içindekileri korur: örneğin iCloud’un eşzamanlı kalmak için tuttukları, bir cüzdan, bir uygulamanın belgeleri veya bir fotoğraf, müzik ya da video arşivi."
}
}
}
@@ -108264,25 +108264,25 @@
"few" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel не переміщує %lld папки звідси, бо захищає те, що в них є, як-от гаманець, документи програми або медіатеку."
+ "value" : "Peel не переміщує %lld папки звідси, бо захищає те, що в них є, як-от дані, які iCloud зберігає для синхронізації, гаманець, документи програми або медіатеку."
}
},
"many" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel не переміщує %lld папок звідси, бо захищає те, що в них є, як-от гаманець, документи програми або медіатеку."
+ "value" : "Peel не переміщує %lld папок звідси, бо захищає те, що в них є, як-от дані, які iCloud зберігає для синхронізації, гаманець, документи програми або медіатеку."
}
},
"one" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel не переміщує %lld папку звідси, бо захищає те, що в ній є, як-от гаманець, документи програми або медіатеку."
+ "value" : "Peel не переміщує %lld папку звідси, бо захищає те, що в ній є, як-от дані, які iCloud зберігає для синхронізації, гаманець, документи програми або медіатеку."
}
},
"other" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel не переміщує %lld папки звідси, бо захищає те, що в них є, як-от гаманець, документи програми або медіатеку."
+ "value" : "Peel не переміщує %lld папки звідси, бо захищає те, що в них є, як-от дані, які iCloud зберігає для синхронізації, гаманець, документи програми або медіатеку."
}
}
}
@@ -108291,13 +108291,13 @@
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel不会触碰此处的%lld个文件夹,因为其中的内容受Peel保护,例如钱包、App的文稿或资料库。"
+ "value" : "Peel不会触碰此处的%lld个文件夹,因为其中的内容受Peel保护,例如iCloud为保持同步而保留的数据、钱包、App的文稿或资料库。"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Peel將這裡的%lld個檔案夾原地保留,因為它會保護其中的內容,例如錢包、App的文件或資料庫。"
+ "value" : "Peel將這裡的%lld個檔案夾原地保留,因為它會保護其中的內容,例如iCloud為保持同步而保存的資料、錢包、App的文件或資料庫。"
}
}
}
diff --git a/Packages/PeelCore/Sources/PeelPrivileged/HelperInterface.swift b/Packages/PeelCore/Sources/PeelPrivileged/HelperInterface.swift
index c0ebdebf..886fc74f 100644
--- a/Packages/PeelCore/Sources/PeelPrivileged/HelperInterface.swift
+++ b/Packages/PeelCore/Sources/PeelPrivileged/HelperInterface.swift
@@ -7,7 +7,7 @@ public enum HelperIdentity {
public static let launchdPlistName = "com.tuguidragos.Peel.Helper.plist"
/// Raise it whenever the helper changes, so Peel never works with a helper of another version. The helper
/// refuses requests that carry any other version.
- public static let protocolVersion = 16
+ public static let protocolVersion = 17
}
/// The complete set of privileged operations. The helper validates every argument itself.
diff --git a/Packages/PeelCore/Sources/PeelPrivileged/ProtectedData.swift b/Packages/PeelCore/Sources/PeelPrivileged/ProtectedData.swift
index 95f67caf..9d696b3b 100644
--- a/Packages/PeelCore/Sources/PeelPrivileged/ProtectedData.swift
+++ b/Packages/PeelCore/Sources/PeelPrivileged/ProtectedData.swift
@@ -197,9 +197,26 @@ public enum ProtectedData: Sendable {
"Library/Nano/backup",
]
- /// Every protected place named from a home folder: `homeFolders`, `homeKeys` and `walletKeys`. `refuses`,
- /// `holds` and `RemovalGuard` all read it, so a place added to one of those lists is protected by all three.
- public static let homeTrees = homeFolders + homeKeys + walletKeys
+ /// What iCloud and File Provider keep about the files on this Mac and in the cloud, and the containers of macOS's
+ /// own services, iCloud's among them. The services that keep these hold them open and make them again, and
+ /// removing one, or putting an old copy back, leaves iCloud Drive's records disagreeing with the files.
+ static let cloudState = [
+ "Library/Application Support/CloudDocs",
+ "Library/Application Support/FileProvider",
+ "Library/Daemon Containers",
+ "Library/Caches/CloudKit",
+ "Library/Caches/com.apple.bird",
+ "Library/Caches/com.apple.cloudd",
+ ]
+
+ /// How the caches of File Provider's and CloudKit's own programs begin in a home's `Library/Caches`: Apple names
+ /// each of them for its program and adds programs between releases, so they are known by that start. Lowercase.
+ private static let cloudStateCaches = ["com.apple.fileprovider", "com.apple.cloudkit"]
+
+ /// Every protected place named from a home folder: `homeFolders`, `homeKeys`, `walletKeys` and `cloudState`.
+ /// `refuses`, `holds` and `RemovalGuard` all read it, so a place added to one of those lists is protected by all
+ /// three.
+ public static let homeTrees = homeFolders + homeKeys + walletKeys + cloudState
/// Hidden items in the home folder that belong to no single app: shells, git, and the folders many tools
/// share. Never removed on any app's behalf, but what sits inside `.config`, `.cache`, and `.local` still
@@ -356,30 +373,40 @@ public enum ProtectedData: Sendable {
private struct Branch {
var endsATree = false
+ /// A name in this folder that begins with one of these is a tree too.
+ var beginnings: [String] = []
var next: [String: Branch] = [:]
- mutating func add(_ names: ArraySlice<String>) {
+ mutating func add(_ names: ArraySlice<String>, beginnings: [String] = []) {
guard let name = names.first else {
- endsATree = true
+ endsATree = endsATree || beginnings.isEmpty
+ self.beginnings += beginnings
return
}
- next[name, default: Branch()].add(names.dropFirst())
+ next[name, default: Branch()].add(names.dropFirst(), beginnings: beginnings)
}
}
- init(_ trees: [[String]]) {
+ /// `trees` are named in full; in each folder of `beginnings`, every name that begins with one of its starts is
+ /// a tree.
+ init(_ trees: [[String]], beginnings: [(folder: [String], starts: [String])] = []) {
var root = Branch()
for tree in trees {
root.add(tree[...])
}
+ for (folder, starts) in beginnings {
+ root.add(folder[...], beginnings: starts)
+ }
self.root = root
- ancestors = Set(trees.flatMap { tree in (0..<tree.count).map { Array(tree[..<$0]) } })
+ let above = { (names: [String]) in (0..<names.count).map { Array(names[..<$0]) } }
+ ancestors = Set(trees.flatMap(above) + beginnings.flatMap { above($0.folder) + [$0.folder] })
}
/// True when `names` is a tree or sits inside one.
func contain(_ names: [String]) -> Bool {
var branch = root
for name in names {
+ if branch.beginnings.contains(where: name.hasPrefix) { return true }
guard let next = branch.next[name] else { return false }
if next.endsATree { return true }
branch = next
@@ -400,8 +427,11 @@ public enum ProtectedData: Sendable {
private static func trees(under home: String) -> Trees {
treesByHome.withLock { cache in
if let trees = cache[home] { return trees }
+ let names = { (path: String) in
+ PathComponents.of((home as NSString).appendingPathComponent(path).lowercased())
+ }
let trees = Trees(
- homeTrees.map { PathComponents.of((home as NSString).appendingPathComponent($0).lowercased()) }
+ homeTrees.map(names), beginnings: [(folder: names("Library/Caches"), starts: cloudStateCaches)]
)
if cache.count >= 32 { cache.removeAll() }
cache[home] = trees
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AttackHelperPolicyTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AttackHelperPolicyTests.swift
index 8879f667..5eb8c7d7 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/AttackHelperPolicyTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/AttackHelperPolicyTests.swift
@@ -19,6 +19,9 @@ struct AttackHelperPolicyTests {
"home/Library/Mobile Documents/com~apple~CloudDocs/Thesis.pages",
"home/Library/Keychains/login.keychain-db",
"home/Library/Messages/chat.db",
+ "home/Library/Application Support/CloudDocs/session/db/client.db",
+ "home/Library/Caches/CloudKit/CloudKitMetadata",
+ "home/Library/Caches/com.apple.FileProviderDaemon.AppStoreService/cache.db",
]
for path in paths {
try directory.file(path)
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AttackRemovalGuardTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AttackRemovalGuardTests.swift
index 93eb6cb6..b7aa4843 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/AttackRemovalGuardTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/AttackRemovalGuardTests.swift
@@ -563,6 +563,49 @@ struct AttackRemovalGuardTests {
}
}
+ @Test func iCloudsAndFileProvidersOwnStateStaysAndNothingIsPutBackThere() throws {
+ let directory = try TemporaryDirectory()
+ let home = directory.url.appending(path: "home", directoryHint: .isDirectory)
+ let homePath = home.path(percentEncoded: false)
+ let state = [
+ "Library/Application Support/CloudDocs/session/db/client.db",
+ "Library/Application Support/FileProvider/5A3E2C1D-0000-4000-8000-000000000001/database/db",
+ "Library/Daemon Containers/5A3E2C1D-0000-4000-8000-000000000002/Data/Library/Caches/state.db",
+ "Library/Caches/CloudKit/CloudKitMetadata",
+ "Library/Caches/CloudKit/org.example.cloudapp/records.db",
+ "Library/Caches/com.apple.bird/session.db",
+ "Library/Caches/com.apple.cloudd/cache.db",
+ "Library/Caches/com.apple.cloudkit/cache.db",
+ "Library/Caches/com.apple.cloudkit.CloudKitDaemon/cache.db",
+ "Library/Caches/com.apple.FileProviderDaemon.AppStoreService/cache.db",
+ "Library/Caches/com.apple.fileproviderd/cache.db",
+ ]
+ let controls = [
+ "Library/Caches/com.apple.Spotlight/index.db",
+ "Library/Caches/org.example.cloudkit/cache.db",
+ "Library/Application Support/org.example.FileProvider/state.db",
+ ]
+ for file in state + controls {
+ try directory.file("home/\(file)")
+ }
+ let trashed = try directory.directory("home/.Trash/CloudKit")
+ let guardian = RemovalGuard(
+ environment: SearchEnvironment(homeDirectory: home, rootDirectory: directory.url.appending(path: "root"))
+ )
+
+ for file in state {
+ let folder = home.appending(path: file).deletingLastPathComponent()
+ for url in [home.appending(path: file), folder] {
+ #expect(!guardian.allowsRemoval(of: url), "\(url.path(percentEncoded: false)) may be removed")
+ #expect(ProtectedData.refuses(url.path(percentEncoded: false), home: homePath), "\(file) is not refused for the helper")
+ }
+ }
+ #expect(!guardian.allowsPuttingBack(trashed, at: home.appending(path: "Library/Caches/CloudKit")))
+ for file in controls {
+ #expect(guardian.allowsRemoval(of: home.appending(path: file).deletingLastPathComponent()), "\(file) is refused")
+ }
+ }
+
/// The guard refuses what is inside a container's `Data/Documents`, where a sandboxed app keeps what its
/// user made. An uninstall lists the container around it, so the container is refused too while that folder
/// holds anything or cannot be read.
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
index 3a4bc261..d1fd5ea4 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift
@@ -1111,6 +1111,20 @@ struct LeftoverScannerTests {
#expect(scan.leftovers.allSatisfy { $0.kind == .plugIns })
}
+ @Test func leavesTheAppsPartOfCloudKitsCacheToCloudKit() async throws {
+ let directory = try TemporaryDirectory()
+ let app = InstalledApp(
+ url: URL(filePath: "/Applications/Cloud App.app"), bundleIdentifier: "org.example.cloudapp", name: "Cloud App"
+ )
+ try directory.file("home/Library/Caches/org.example.cloudapp/blob")
+ try directory.file("home/Library/Caches/CloudKit/org.example.cloudapp/records.db")
+
+ let scan = await LeftoverScanner(environment: environment(in: directory)).scan(app, installedApps: [app])
+
+ let found = scan.leftovers.map(\.url)
+ #expect(found.map { $0.deletingLastPathComponent().lastPathComponent } == ["Caches"], "\(found)")
+ }
+
@Test func findsTheAppsMailBundle() async throws {
let directory = try TemporaryDirectory()
let app = InstalledApp(
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swift
index 138546c3..d8fe20c7 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/SpaceRemovalTests.swift
@@ -134,7 +134,7 @@ struct SpaceRemovalTests {
@Test func neverSelectsACacheMacOSKeepsForItself() async throws {
let directory = try TemporaryDirectory()
- for name in ["com.apple.Spotlight", "CloudKit", "familycircled", "GameStoreKit", "org.example.notes", "com.gone.app"] {
+ 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")
@@ -150,14 +150,28 @@ struct SpaceRemovalTests {
let caches = await SpaceRemoval.plan(for: item(directory), environment: environment(directory), running: [:])
let logged = await SpaceRemoval.plan(for: logs, environment: environment(directory), running: [:])
- let all = ["CloudKit", "GameStoreKit", "com.apple.Spotlight", "com.gone.app", "familycircled", "org.example.notes"]
+ let all = ["GameStoreKit", "com.apple.Spotlight", "com.gone.app", "familycircled", "org.example.notes"]
#expect(names(caches.removable) == all)
#expect(names(Array(caches.suggested)) == ["com.gone.app", "org.example.notes"])
let keptByMacOS = caches.heldBack.filter { $0.value == .keptByMacOS }.map(\.key)
- #expect(names(keptByMacOS) == ["CloudKit", "GameStoreKit", "com.apple.Spotlight", "familycircled"])
+ #expect(names(keptByMacOS) == ["GameStoreKit", "com.apple.Spotlight", "familycircled"])
#expect(names(Array(logged.suggested)) == ["com.apple.example"])
}
+ @Test func leavesICloudsOwnStateInTheCachesAlone() async throws {
+ let directory = try TemporaryDirectory()
+ let state = ["CloudKit", "com.apple.bird", "com.apple.FileProviderDaemon.AppStoreService"]
+ for name in state + ["com.apple.Spotlight", "org.example.notes"] {
+ try directory.file("home/Library/Caches/\(name)/data.db")
+ }
+
+ let plan = await SpaceRemoval.plan(for: item(directory), environment: environment(directory), running: [:])
+
+ #expect(plan.removable.map(\.lastPathComponent).sorted() == ["com.apple.Spotlight", "org.example.notes"])
+ #expect(plan.refused.keys.map(\.lastPathComponent).sorted() == state.sorted())
+ #expect(plan.refused.values.allSatisfy { $0 == .protectedLocation })
+ }
+
/// macOS's own services keep theirs, Developer's go to Developer, and the folder itself is never offered.
@Test func plansTheFolderMacOSGivesTheAccountForCachesWithoutMacOSsOwn() async throws {
let directory = try TemporaryDirectory()
diff --git a/Peel/Views/Space/SpaceDetailView.swift b/Peel/Views/Space/SpaceDetailView.swift
index 278d6929..a83a5850 100644
--- a/Peel/Views/Space/SpaceDetailView.swift
+++ b/Peel/Views/Space/SpaceDetailView.swift
@@ -157,7 +157,7 @@ struct SpaceDetailView: View {
Text("Peel leaves ^[\(keepingWork) folder](inflect: true) here alone because an app keeps work there that exists nowhere else, such as an editor’s local history.")
}
if plan.refused.count > keepingWork {
- Text("Peel leaves ^[\(plan.refused.count - keepingWork) folder](inflect: true) here alone because it protects what is there, such as a wallet, an app’s documents, or a library.")
+ Text("Peel leaves ^[\(plan.refused.count - keepingWork) folder](inflect: true) here alone because it protects what is there, such as what iCloud keeps to stay in sync, a wallet, an app’s documents, or a library.")
}
}
.font(.callout)
diff --git a/SAFETY.md b/SAFETY.md
index 57db6332..4a0890c8 100644
--- a/SAFETY.md
+++ b/SAFETY.md
@@ -31,6 +31,8 @@ In the Library of every account on the Mac and, for the last rows, in the home f
| --- | --- |
| `Mobile Documents` | iCloud Drive. A file removed here is removed from every device you own. |
| `CloudStorage` | Dropbox, Google Drive, OneDrive, and the rest. Same reason. |
+| `Application Support/CloudDocs`, `Application Support/FileProvider`, `Daemon Containers` | What iCloud Drive and File Provider keep about which files are on this Mac and which are in the cloud, and the containers of macOS's own services. Their services hold these open and make them again: removing one, or putting an old copy back, leaves iCloud Drive's records disagreeing with your files. |
+| `Caches/CloudKit`, `Caches/com.apple.bird`, `Caches/com.apple.cloudd`, and every folder in `Caches` whose name begins with `com.apple.cloudkit` or `com.apple.FileProvider` | The same records, in the caches of iCloud's and File Provider's own programs. |
| `Keychains` | Your passwords and keys. |
| `Passes` | Wallet. |
| `Spelling`, `KeyboardServices` | Words you taught the Mac, and your text replacements. |
@@ -292,8 +294,8 @@ Never selected for you, even when found:
and the reports macOS wrote when an app crashed, which its developer may still ask for.
- Model weights, the packages a tool keeps installed outside your projects, virtual environments, the installers and
boxes a tool keeps for you to install again, and an editor's saved state for a project that no longer exists.
-- A cache macOS keeps for its own services in `~/Library/Caches` (Spotlight's, iCloud's, the fonts') or in the container
- of one of Apple's apps.
+- 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.
- `/Users/Shared`: it belongs to every account, not just yours.
- A project you worked on this week, and a download that changed in the last day, which may still be going.
- A folder with a repository, a wallet, a signing key, or a password database (KeePass's `.kdbx`, KeePassXC's `.keyx`)