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
Name the app that syncs what Peel leaves alone, and its marker
Țugui Dragoș733f6f3c7d9c
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex bdafaab5..95a874e1 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -5280,6 +5280,118 @@}}},+ "%@ syncs some of them to your other devices (its marker is %@)." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Aplikace %1$@ synchronizuje některé z nich s vašimi ostatními zařízeními (její značka je %2$@)."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ synchronisiert einige davon mit deinen anderen Geräten (Markierung: %2$@)."+ }+ },+ "en" : {+ "stringUnit" : {+ "state" : "new",+ "value" : "%1$@ syncs some of them to your other devices (its marker is %2$@)."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ sincroniza algunos de ellos con tus otros dispositivos (su marcador es %2$@)."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ synchronise certains d’entre eux avec vos autres appareils (son marqueur est %2$@)."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ ne sincronizza alcuni con gli altri tuoi dispositivi (il suo marcatore è %2$@)."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "それらのファイルの一部は、“%1$@”を通じてほかのデバイスに同期されます(目印は%2$@)。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "그중 일부는 ‘%1$@’을(를) 통해 다른 기기와 동기화됩니다(표식: %2$@)."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ synchroniseert een deel ervan met je andere apparaten (de markering is %2$@)."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Aplikacja %1$@ synchronizuje część tych plików z Twoimi pozostałymi urządzeniami (jej znacznik to %2$@)."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "O %1$@ sincroniza alguns deles com os seus outros dispositivos (o marcador dele é %2$@)."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ sincronizează unele dintre aceste fișiere pe celelalte dispozitive ale dvs. (marcajul său este %2$@)."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Некоторые из них синхронизируются с другими Вашими устройствами через приложение «%1$@» (маркер: %2$@)."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ synkroniserar några av dem till dina andra enheter (dess markör är %2$@)."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@, bu dosyaların bir kısmını diğer aygıtlarınızla eşzamanlıyor (işaretçisi: %2$@)."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Деякі з них синхронізуються з іншими вашими пристроями через програму «%1$@» (її маркер: %2$@)."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“%1$@”会将其中一些文件同步到你的其他设备(其标记为“%2$@”)。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "「%1$@」會將其中部分檔案與你的其他裝置同步(其標記為「%2$@」)。"+ }+ }+ }+ },"%@ used" : {"localizations" : {"cs" : {@@ -69271,6 +69383,118 @@}}},+ "It is in a folder %@ syncs to your other devices (its marker is %@), which Peel leaves to that app." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Je ve složce, která se synchronizuje přes aplikaci %1$@ s vašimi ostatními zařízeními (její značka je %2$@) a kterou Peel přenechává této aplikaci."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Dieser Ordner liegt in einem Ordner, der über %1$@ mit deinen anderen Geräten synchronisiert wird (Markierung: %2$@) und den Peel dieser App überlässt."+ }+ },+ "en" : {+ "stringUnit" : {+ "state" : "new",+ "value" : "It is in a folder %1$@ syncs to your other devices (its marker is %2$@), which Peel leaves to that app."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Está en una carpeta que %1$@ sincroniza con tus otros dispositivos (su marcador es %2$@), y que Peel deja en manos de esa app."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Il se trouve dans un dossier que %1$@ synchronise avec vos autres appareils (son marqueur est %2$@) et que Peel laisse à cette app."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Si trova in una cartella che %1$@ sincronizza con gli altri tuoi dispositivi (il suo marcatore è %2$@), e che Peel lascia a quell’app."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "“%1$@”を通じてほかのデバイスに同期されているフォルダ(目印は%2$@)にあり、Peelはそれをそのアプリに任せています。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "‘%1$@’을(를) 통해 다른 기기와 동기화되는 폴더(표식: %2$@)에 있습니다. Peel은 이러한 폴더를 해당 앱에 맡깁니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Het staat in een map die wordt gesynchroniseerd met je andere apparaten via %1$@ (de markering is %2$@), en die Peel overlaat aan die app."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Jest w folderze synchronizowanym z Twoimi pozostałymi urządzeniami przez aplikację %1$@ (jej znacznik to %2$@), który Peel zostawia tej aplikacji."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Está em uma pasta que o %1$@ sincroniza com os seus outros dispositivos (o marcador dela é %2$@), e o Peel a deixa para esse app."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Se află într‑un dosar care se sincronizează pe celelalte dispozitive ale dvs. prin %1$@ (marcajul său este %2$@), iar Peel îl lasă în seama acestei aplicații."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Эта папка находится в папке, которая синхронизируется с другими Вашими устройствами через приложение «%1$@» (маркер: %2$@), и Peel оставляет ее этому приложению."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Den ligger i en mapp som %1$@ synkroniserar till dina andra enheter (dess markör är %2$@), och som Peel lämnar åt den appen."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ aracılığıyla diğer aygıtlarınızla eşzamanlanan bir klasörde (işaretçisi: %2$@); Peel bunu o uygulamaya bırakır."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Папка лежить у папці, яка синхронізується з іншими вашими пристроями через програму «%1$@» (її маркер: %2$@), а таку папку Peel залишає тій програмі."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "它位于一个通过“%1$@”同步到你的其他设备的文件夹中(其标记为“%2$@”),Peel会将其交给该App处理。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "它位於會透過「%1$@」與你的其他裝置同步的檔案夾中(其標記為「%2$@」),Peel會交由該App處理。"+ }+ }+ }+ },"It is in a folder that syncs to your other devices through iCloud or another app, which Peel leaves to that app." : {"localizations" : {"cs" : {@@ -81420,6 +81644,118 @@}}},+ "Left alone: this is in a folder %@ syncs to your other devices (its marker is %@), and moving it to the Trash would also remove it from them." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nedotčeno: tato položka je ve složce, která se synchronizuje přes aplikaci %1$@ s vašimi ostatními zařízeními (její značka je %2$@), a přesunutím do koše byste ji odstranili také z nich."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Unangetastet: Dieses Objekt liegt in einem Ordner, der über %1$@ mit deinen anderen Geräten synchronisiert wird (Markierung: %2$@), und es in den Papierkorb zu legen, würde es auch von ihnen entfernen."+ }+ },+ "en" : {+ "stringUnit" : {+ "state" : "new",+ "value" : "Left alone: this is in a folder %1$@ syncs to your other devices (its marker is %2$@), and moving it to the Trash would also remove it from them."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "No se toca: está en una carpeta que %1$@ sincroniza con tus otros dispositivos (su marcador es %2$@), y trasladarlo a la papelera también lo eliminaría de ellos."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Laissé en place : cet élément se trouve dans un dossier que %1$@ synchronise avec vos autres appareils (son marqueur est %2$@), et le placer dans la corbeille le supprimerait aussi de ces appareils."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Resta dov’è: si trova in una cartella che %1$@ sincronizza con gli altri tuoi dispositivi (il suo marcatore è %2$@), e spostarlo nel Cestino lo rimuoverebbe anche da quei dispositivi."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "対象外: これは“%1$@”を通じてほかのデバイスに同期されているフォルダ(目印は%2$@)にあるため、ゴミ箱に入れると、それらのデバイスからも削除されます。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "그대로 둠: 이 항목은 ‘%1$@’을(를) 통해 다른 기기와 동기화되는 폴더(표식: %2$@)에 있으며, 휴지통으로 이동하면 해당 기기에서도 삭제됩니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Blijft staan: dit bevindt zich in een map die wordt gesynchroniseerd met je andere apparaten via %1$@ (de markering is %2$@), en als je het naar de prullenmand verplaatst, verdwijnt het ook van die apparaten."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nietknięte: jest w folderze synchronizowanym z Twoimi pozostałymi urządzeniami przez aplikację %1$@ (jej znacznik to %2$@), a po przeniesieniu do Kosza zostałoby usunięte także z nich."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Preservado: este item está em uma pasta que o %1$@ sincroniza com os seus outros dispositivos (o marcador dela é %2$@), e movê-lo para o Lixo também o removeria deles."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Lăsat neatins: acest articol se află într‑un dosar care se sincronizează pe celelalte dispozitive ale dvs. prin %1$@ (marcajul său este %2$@), iar mutarea lui în Coș l‑ar elimina și de pe acestea."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Остается на месте: этот объект находится в папке, которая синхронизируется с другими Вашими устройствами через приложение «%1$@» (маркер: %2$@), и, если переместить его в Корзину, он будет удален также с этих устройств."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Rörs inte: det här ligger i en mapp som %1$@ synkroniserar till dina andra enheter (dess markör är %2$@), och om det flyttades till papperskorgen skulle det också tas bort från dem."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Yerinde kalır: bu, %1$@ aracılığıyla diğer aygıtlarınızla eşzamanlanan bir klasörde (işaretçisi: %2$@) bulunuyor ve Çöp Sepeti’ne taşınırsa onlardan da silinir."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Лишається на місці: цей елемент лежить у папці, яка синхронізується з іншими вашими пристроями через програму «%1$@» (її маркер: %2$@), і переміщення в Смітник також прибрало б його з них."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "留在原处:此项位于一个通过“%1$@”同步到你的其他设备的文件夹中(其标记为“%2$@”),如果将它移到废纸篓,它也会从这些设备中删除。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "原地保留:此項目位於會透過「%1$@」與你的其他裝置同步的檔案夾中(其標記為「%2$@」),丟到「垃圾桶」也會將它從這些裝置上移除。"+ }+ }+ }+ },"Left alone: this syncs to your other devices through iCloud or another app, and moving it to the Trash would also remove it from them." : {"localizations" : {"cs" : {@@ -138077,6 +138413,118 @@}}},+ "Peel won’t move this: it is in a folder %@ syncs to your other devices (its marker is %@), and moving it to the Trash would also remove it from them." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel tuto položku nepřesune: je ve složce, která se synchronizuje přes aplikaci %1$@ s vašimi ostatními zařízeními (její značka je %2$@), a přesunutím do koše byste ji odstranili také z nich."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel verschiebt dies nicht: Es liegt in einem Ordner, der über %1$@ mit deinen anderen Geräten synchronisiert wird (Markierung: %2$@), und es in den Papierkorb zu legen, würde es auch von ihnen entfernen."+ }+ },+ "en" : {+ "stringUnit" : {+ "state" : "new",+ "value" : "Peel won’t move this: it is in a folder %1$@ syncs to your other devices (its marker is %2$@), and moving it to the Trash would also remove it from them."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel no trasladará esto: está en una carpeta que %1$@ sincroniza con tus otros dispositivos (su marcador es %2$@), y trasladarlo a la papelera también lo eliminaría de ellos."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel refuse de déplacer cet élément : il se trouve dans un dossier que %1$@ synchronise avec vos autres appareils (son marqueur est %2$@), et le placer dans la corbeille le supprimerait aussi de ces appareils."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel non lo sposta: si trova in una cartella che %1$@ sincronizza con gli altri tuoi dispositivi (il suo marcatore è %2$@), e spostarlo nel Cestino lo rimuoverebbe anche da quei dispositivi."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peelはこれを移動しません。“%1$@”を通じてほかのデバイスに同期されているフォルダ(目印は%2$@)にあるため、ゴミ箱に入れると、それらのデバイスからも削除されます。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel이 이 항목을 이동하지 않습니다. ‘%1$@’을(를) 통해 다른 기기와 동기화되는 폴더(표식: %2$@)에 있으며, 휴지통으로 이동하면 해당 기기에서도 삭제되기 때문입니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel verplaatst dit niet: het staat in een map die wordt gesynchroniseerd met je andere apparaten via %1$@ (de markering is %2$@), en als je het naar de prullenmand verplaatst, verdwijnt het ook van die apparaten."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel tego nie przeniesie: jest w folderze synchronizowanym z Twoimi pozostałymi urządzeniami przez aplikację %1$@ (jej znacznik to %2$@), a po przeniesieniu do Kosza zostałoby usunięte także z nich."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "O Peel não vai mover isto: está em uma pasta que o %1$@ sincroniza com os seus outros dispositivos (o marcador dela é %2$@), e movê-lo para o Lixo também o removeria deles."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel nu mută acest articol: se află într‑un dosar care se sincronizează pe celelalte dispozitive ale dvs. prin %1$@ (marcajul său este %2$@), iar mutarea lui în Coș l‑ar elimina și de pe acestea."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel не будет это перемещать: объект находится в папке, которая синхронизируется с другими Вашими устройствами через приложение «%1$@» (маркер: %2$@), и, если переместить его в Корзину, он будет удален также с этих устройств."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel flyttar inte det här: det ligger i en mapp som %1$@ synkroniserar till dina andra enheter (dess markör är %2$@), och om det flyttades till papperskorgen skulle det också tas bort från dem."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel bunu taşımaz: %1$@ aracılığıyla diğer aygıtlarınızla eşzamanlanan bir klasörde (işaretçisi: %2$@) bulunuyor ve Çöp Sepeti’ne taşınırsa onlardan da silinir."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel не перемістить це: елемент лежить у папці, яка синхронізується з іншими вашими пристроями через програму «%1$@» (її маркер: %2$@), і переміщення в Смітник також прибрало б його з них."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel不会移动此项:它位于一个通过“%1$@”同步到你的其他设备的文件夹中(其标记为“%2$@”),如果将它移到废纸篓,它也会从这些设备中删除。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel不會移動此項目:它位於會透過「%1$@」與你的其他裝置同步的檔案夾中(其標記為「%2$@」),丟到「垃圾桶」也會將它從這些裝置上移除。"+ }+ }+ }+ },"Peel won’t move this: it is part of macOS, or inside something Peel protects." : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swiftindex 87caf037..e6cdfd40 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/AppCommands.swift@@ -216,7 +216,7 @@ struct LeftoversCommand: AsyncParsableCommand {static func summary(of leftover: Leftover) -> String {var summary = leftover.match.reason.summaryif let heldBack = leftover.match.heldBack {- summary += ", review: \(heldBack.summary)"+ summary += ", review: \(heldBack.summary(keptInStepBy: leftover.syncedBy))"} else if !leftover.match.isRecommended {let users = leftover.match.sharedWith + leftover.match.otherCopies.map(Output.path)summary += leftover.match.isShareddiff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swiftindex 60a05fd0..e93cdc5c 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift@@ -731,6 +731,8 @@ struct DuplicatesCommand: AsyncParsableCommand {let files: [String]/// The copies that sync to other devices, listed and never moved.let synced: [String]+ /// The apps that sync those copies, each with its marker.+ let syncedBy: [SyncRecord]/// The copies with Finder tags, a Finder comment, or a resource fork the others lack, never moved.let stays: [String]}@@ -835,6 +837,7 @@ struct DuplicatesCommand: AsyncParsableCommand {let synced = scan.groups.reduce(0) { total, group in total + group.files.count { $0.heldBack == .inTheCloud } }if synced > 0 {notes.append("\(Output.count(synced, "copy syncs", "copies sync")) to your other devices, so Peel lists them as copies that stay and never moves them.")+ notes += keepers(of: scan.groups.flatMap(\.files)).compactMap(\.note)}let staying = scan.groups.reduce(0) { total, group intotal + group.files.count { $0.heldBack == .keepsWhatTheOthersLack }@@ -845,6 +848,13 @@ struct DuplicatesCommand: AsyncParsableCommand {return notes}+ /// The apps that sync the copies held back for syncing through one, each marker once, in the order found.+ static func keepers(of files: [DuplicateFile]) -> [SyncKeeper] {+ files.filter { $0.heldBack == .inTheCloud }.compactMap(\.syncedBy).reduce(into: []) { keepers, keeper in+ if !keepers.contains(keeper) { keepers.append(keeper) }+ }+ }+static func found(in scan: DuplicateScan) -> Found {Found(folders: scan.folderGroups.map { group in@@ -861,6 +871,7 @@ struct DuplicatesCommand: AsyncParsableCommand {reclaimableSize: group.reclaimableSize,files: group.movableFiles.map { Output.path($0.url) },synced: group.files.filter { $0.heldBack == .inTheCloud }.map { Output.path($0.url) },+ syncedBy: keepers(of: group.files).compactMap(\.record),stays: group.files.filter { $0.heldBack == .keepsWhatTheOthersLack }.map { Output.path($0.url) })},@@ -1037,7 +1048,9 @@ struct SearchCommand: AsyncParsableCommand {Output.note("Only the first \(Output.number(FileSearch.maximumResults)) files are shown, yours before those an app keeps in a Library folder, each largest first. Narrow the search to see the rest.")}for reason in FileSearch.LeftOut.allCases {- if let count = results.leftOut[reason] { Output.note(Self.note(for: reason, count: count)) }+ guard let count = results.leftOut[reason] else { continue }+ Output.note(Self.note(for: reason, count: count))+ if reason == .syncs { results.syncedBy.compactMap(\.note).forEach(Output.note) }}if !results.unindexedDisks.isEmpty {let unindexed = results.unindexedDisks.map(Output.plain).joined(separator: ", ")diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex 41626242..0a8ffc23 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -337,7 +337,9 @@ extension GuardRefusal {case .staysItself: "a folder that stays in place, though what is inside may go"case .protectedLocation: "part of macOS, or inside something Peel protects"case .holdsProtectedData: "holds something Peel protects, such as a keychain or a wallet"- case .inTheCloud: "syncs to your other devices through iCloud or another app, so moving it would remove it from them too"+ case .inTheCloud(.cloud): "syncs to your other devices through iCloud or another app, so moving it would remove it from them too"+ case .inTheCloud(.app(let app, let marker)):+ "in a folder \(app.name) syncs to your other devices (its marker is \(Output.plain(Output.path(marker)))), so moving it would remove it from them too"case .holdsDocuments: "holds an app's documents"case .holdsALibrary: "holds a photo, music, or video library"case .holdsWorkKeptInACache: "holds work an app keeps nowhere else, such as an editor's local history"@@ -346,7 +348,32 @@ extension GuardRefusal {}}+extension SyncKeeper {+ /// A note naming the app that syncs some of the items counted, and its marker, or nil for iCloud.+ var note: String? {+ guard case .app(let app, let marker) = self else { return nil }+ return "\(app.name) syncs some of them to your other devices (its marker is \(Output.plain(Output.path(marker))))."+ }++ var record: SyncRecord? {+ guard case .app(let app, let marker) = self else { return nil }+ return SyncRecord(app: app.name, marker: Output.path(marker))+ }+}++/// The app that syncs an item, and the marker it keeps at the root of the folder it syncs.+struct SyncRecord: Encodable, Equatable {+ let app: String+ let marker: String+}+extension HoldBack {+ /// The summary, naming the app that keeps the item in step and its marker when one does.+ func summary(keptInStepBy keeper: SyncKeeper?) -> String {+ guard self == .inTheCloud, case .app(let app, let marker)? = keeper else { return summary }+ return "in a folder \(app.name) syncs to your other devices (its marker is \(Output.plain(Output.path(marker)))), so moving it would remove it from them too"+ }+/// Why the item was held back, the same reason the app's rows give, in the command line's plain English.var summary: String {switch self {@@ -431,7 +458,9 @@ extension ProjectArtifacts.Refusal {switch self {case .tooBroad: "a whole home folder or disk is too much to search"case .systemFolder: "it is a folder that macOS or every account uses, not a folder of projects"- case .inTheCloud: "it is in a folder that syncs to your other devices through iCloud or another app, which Peel leaves to that app"+ case .inTheCloud(.cloud): "it is in a folder that syncs to your other devices through iCloud or another app, which Peel leaves to that app"+ case .inTheCloud(.app(let app, let marker)):+ "it is in a folder \(app.name) syncs to your other devices (its marker is \(Output.plain(Output.path(marker)))), which Peel leaves to that app"case .notAFolder: "it isn't a folder Peel can reach"case .inAPackage: "it is an app or another package, or inside one, and what is inside belongs to it"case .neverSearched: "it is a hidden folder, a Library, or a folder a tool fills, such as node_modules, or it sits inside one, where apps and tools keep what they install"diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Records.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Records.swiftindex db5968aa..9d02fbcb 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Records.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Records.swift@@ -44,6 +44,8 @@ struct LeftoverRecord: Encodable {let confidence: String/// Why Peel left the item unselected on purpose, or `null` when it didn't.let heldBack: String?+ /// The app that syncs the item and its marker, when it is held back for syncing through one, or `null`.+ let syncedBy: SyncRecord?let sharedWith: [String]/// Other copies of the app that use the item too, by their place, since they share its identifier.let otherCopies: [String]@@ -56,6 +58,7 @@ struct LeftoverRecord: Encodable {reason = leftover.match.reason.rawValueconfidence = leftover.match.confidence.summaryheldBack = leftover.match.heldBack?.rawValue+ syncedBy = leftover.match.heldBack == .inTheCloud ? leftover.syncedBy?.record : nilsharedWith = leftover.match.sharedWithotherCopies = leftover.match.otherCopies.map(Output.path)isRecommended = leftover.match.isRecommended@@ -68,6 +71,7 @@ struct LeftoverRecord: Encodable {case reasoncase confidencecase heldBack+ case syncedBycase sharedWithcase otherCopiescase isRecommended@@ -82,6 +86,7 @@ struct LeftoverRecord: Encodable {try container.encode(reason, forKey: .reason)try container.encode(confidence, forKey: .confidence)try container.encode(heldBack, forKey: .heldBack)+ try container.encode(syncedBy, forKey: .syncedBy)try container.encode(sharedWith, forKey: .sharedWith)try container.encode(otherCopies, forKey: .otherCopies)try container.encode(isRecommended, forKey: .isRecommended)diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swiftindex 36ef2de3..441cca6e 100644--- a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift+++ b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift@@ -982,7 +982,7 @@ public enum ProjectArtifacts {case tooBroad/// A folder macOS or every account uses, such as `/Applications`, `/opt`, or `/Users/Shared`.case systemFolder- case inTheCloud+ case inTheCloud(SyncKeeper)case notAFolder/// An app or another package, or a folder inside one: what is inside belongs to it.case inAPackage@@ -1034,7 +1034,7 @@ public enum ProjectArtifacts {let isInACloudFolder = zip(components, components.dropFirst()).contains { folder, inside infolder == "library" && ["mobile documents", "cloudstorage"].contains(inside)}- if isInACloudFolder { return .inTheCloud }+ if isInACloudFolder { return .inTheCloud(.cloud) }if homes.contains(path) { return .tooBroad }// The data volume's own path reaches the same folders as the path without it.let names = components.starts(with: ["system", "volumes", "data"]) ? Array(components.dropFirst(3)) : components@@ -1050,7 +1050,7 @@ public enum ProjectArtifacts {FileManager.default.fileExists(atPath: PathPattern.comparablePath(of: root), isDirectory: &isDirectory)&& isDirectory.boolValueguard isThere else { return .notAFolder }- if SyncedFolders().syncsToOtherDevices(root) { return .inTheCloud }+ if let keeper = SyncedFolders().keeper(of: root) { return .inTheCloud(keeper) }if root.isOrIsInsideAPackage { return .inAPackage }return PathComponents.of(kernelName).contains(where: isSkipped) ? .neverSearched : nil}diff --git a/Packages/PeelCore/Sources/PeelCore/Duplicates/DuplicateFinder.swift b/Packages/PeelCore/Sources/PeelCore/Duplicates/DuplicateFinder.swiftindex fa1ee136..3fc2f334 100644--- a/Packages/PeelCore/Sources/PeelCore/Duplicates/DuplicateFinder.swift+++ b/Packages/PeelCore/Sources/PeelCore/Duplicates/DuplicateFinder.swift@@ -226,7 +226,7 @@ public struct DuplicateFinder: Sendable {Self.grouped(sampled),names: names,refusal: removalGuard.refusal(of:),- syncsToOtherDevices: { synced.syncsToOtherDevices($0) || Self.isInACloudFolder(Self.path(of: $0)) }+ syncKeeper: { Self.isInACloudFolder(Self.path(of: $0)) ? .cloud : synced.keeper(of: $0) })let finalGroups = sampledGroups.filter { !FileDigest.isSampled(size: $0[0].item.identity.size) }@@ -258,6 +258,8 @@ public struct DuplicateFinder: Sendable {let identity: FileIdentity/// Set by `movable` for a copy that is kept in its group but never moved.var heldBack: HoldBack? = nil+ /// What keeps a copy held back as `inTheCloud` in step with the other devices.+ var syncedBy: SyncKeeper? = nil}typealias HashedCandidate = (item: Candidate, digest: ContentDigest)@@ -360,7 +362,7 @@ public struct DuplicateFinder: Sendable {_ groups: [[HashedCandidate]],names: [FileIdentity.Link: [Candidate]],refusal: (URL) -> GuardRefusal?,- syncsToOtherDevices: (URL) -> Bool+ syncKeeper: (URL) -> SyncKeeper?) throws(CancellationError) -> [[HashedCandidate]] {var asked = 0var movable: [[HashedCandidate]] = []@@ -378,9 +380,10 @@ public struct DuplicateFinder: Sendable {synced = nilbreak}- if synced == nil, syncsToOtherDevices(name.url) {+ if synced == nil, let keeper = syncKeeper(name.url) {var held = nameheld.heldBack = .inTheCloud+ held.syncedBy = keepersynced = held}}@@ -433,8 +436,7 @@ public struct DuplicateFinder: Sendable {allocatedSize: ReclaimableSpace.allocated(candidate.url),identity: candidate.identity,heldBack: candidate.heldBack,- syncsThroughACloud: candidate.heldBack == .inTheCloud- && (candidate.url.isInTheCloud || Self.isInACloudFolder(Self.path(of: candidate.url)))+ syncedBy: candidate.heldBack == .inTheCloud ? candidate.syncedBy : nil)}let group = DuplicateGroup(id: members[0].digest.hexadecimal, files: files)diff --git a/Packages/PeelCore/Sources/PeelCore/Duplicates/Duplicates.swift b/Packages/PeelCore/Sources/PeelCore/Duplicates/Duplicates.swiftindex a8757be1..8e0375c2 100644--- a/Packages/PeelCore/Sources/PeelCore/Duplicates/Duplicates.swift+++ b/Packages/PeelCore/Sources/PeelCore/Duplicates/Duplicates.swift@@ -42,9 +42,14 @@ public struct DuplicateFile: Sendable, Hashable, Identifiable {/// Why the copy is listed but never moved: it syncs to the person's other devices, where a move to the Trash/// would remove it too. Nil for a copy that may move.public var heldBack: HoldBack? = nil+ /// What keeps a copy held back as `inTheCloud` in step with the other devices.+ public var syncedBy: SyncKeeper? = nil+/// True for a copy that syncs through iCloud Drive or a cloud's File Provider, rather than through an app that/// keeps folders in step between devices, such as Syncthing.- public var syncsThroughACloud = false+ public var syncsThroughACloud: Bool {+ syncedBy == .cloud+ }public var id: URL { url }diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swiftindex 21971e3f..2df5ae20 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift@@ -324,6 +324,8 @@ public struct Leftover: Sendable, Hashable, Identifiable {/// True when only an administrator can move it, from a place the helper may not move it from, and nothing else/// holds it back.public var isLeftForAnAdministrator = false+ /// What keeps it in step with the other devices, when it is held back as `inTheCloud`.+ public var syncedBy: SyncKeeper? = nilpublic var id: URL { url }@@ -331,7 +333,7 @@ public struct Leftover: Sendable, Hashable, Identifiable {Leftover(url: url, kind: kind, match: match.sharing(with: apps), size: size, isMeasured: isMeasured,requiresPrivileges: requiresPrivileges, holdsDamagedSettings: holdsDamagedSettings,- isLeftForAnAdministrator: isLeftForAnAdministrator+ isLeftForAnAdministrator: isLeftForAnAdministrator, syncedBy: syncedBy)}@@ -342,7 +344,7 @@ public struct Leftover: Sendable, Hashable, Identifiable {return Leftover(url: url, kind: kind, match: match.forReview(reason), size: size, isMeasured: isMeasured,requiresPrivileges: requiresPrivileges, holdsDamagedSettings: holdsDamagedSettings,- isLeftForAnAdministrator: isLeftForAnAdministrator+ isLeftForAnAdministrator: isLeftForAnAdministrator, syncedBy: syncedBy)}}diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swiftindex 0d3f94d4..4587660c 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/LeftoverScanner.swift@@ -380,7 +380,7 @@ public struct LeftoverScanner: Sendable {root: String,foldersAbove: FoldersAbove = .itsOwn,measure: Measure = LeftoverScanner.walk,- syncsToOtherDevices: (URL) -> Bool = SyncedFolders().syncsToOtherDevices+ syncKeeper: (URL) -> SyncKeeper? = SyncedFolders().keeper(of:)) async -> Leftover {// The walk that measures the folder also reports whether it saw a repository or a wallet, so neither// check costs extra reading. A repository means the folder holds more than the app's state, such as work@@ -396,27 +396,28 @@ public struct LeftoverScanner: Sendable {// What the guard will refuse comes first, whatever the walk saw. A folder macOS refuses to open would read// as empty, and an empty folder of the app's own would be selected. From macOS 27, another team's container// is refused outright rather than prompted for.- let heldBack: HoldBack? = if ProtectedData.holds(path, home: home) || wallet == .found {- .holdsKeys+ let held: (HoldBack?, SyncKeeper?) = if ProtectedData.holds(path, home: home) || wallet == .found {+ (.holdsKeys, nil)} else if kind == .containers, ProtectedData.holdsAContainersDocuments(path) {- .holdsDocuments+ (.holdsDocuments, nil)} else if library == .found {- .holdsALibrary+ (.holdsALibrary, nil)} else if work == .found {- .holdsWorkKeptInACache+ (.holdsWorkKeptInACache, nil)} else if !requiresPrivileges, [wallet, library, work].contains(.notKnown) {- .couldNotLookInside- } else if syncsToOtherDevices(url) {- .inTheCloud+ (.couldNotLookInside, nil)+ } else if let keeper = syncKeeper(url) {+ (.inTheCloud, keeper)} else if let keptOnlyHere = KeptOnlyHere.reason(for: path, home: home, root: root) {- keptOnlyHere+ (keptOnlyHere, nil)} else if let contents, contents.couldNotBeRead {- HoldBack.unread(contents)+ (HoldBack.unread(contents), nil)} else if let contents {- heldBack(match, at: url, in: kind, contents: contents, foldersAbove: foldersAbove)+ (heldBack(match, at: url, in: kind, contents: contents, foldersAbove: foldersAbove), nil)} else {- .notMeasured+ (.notMeasured, nil)}+ let (heldBack, syncedBy) = heldreturn Leftover(url: url,kind: kind,@@ -424,7 +425,8 @@ public struct LeftoverScanner: Sendable {size: contents?.size ?? 0,isMeasured: contents.map { !$0.couldNotBeRead } ?? false,requiresPrivileges: requiresPrivileges,- holdsDamagedSettings: kind == .preferences && PreferenceFile.isDamaged(url)+ holdsDamagedSettings: kind == .preferences && PreferenceFile.isDamaged(url),+ syncedBy: syncedBy)}diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift b/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swiftindex d9a47150..c7146752 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/BulkUninstallation.swift@@ -37,6 +37,8 @@ public struct BulkUninstallation: Sendable {public var enclosingPackage: URL?/// True for a preference file that is no property list (`PreferenceFile.isDamaged`).public var holdsDamagedSettings = false+ /// What keeps it in step with the other devices, when it is held back as `inTheCloud`.+ public var syncedBy: SyncKeeper?public var id: URL { url }@@ -260,7 +262,8 @@ public struct BulkUninstallation: Sendable {removedElsewhere: existing.removedElsewhere ?? item.removedElsewhere,isInTheTrash: existing.isInTheTrash || item.isInTheTrash,enclosingPackage: existing.enclosingPackage ?? item.enclosingPackage,- holdsDamagedSettings: existing.holdsDamagedSettings || item.holdsDamagedSettings+ holdsDamagedSettings: existing.holdsDamagedSettings || item.holdsDamagedSettings,+ syncedBy: existing.syncedBy ?? item.syncedBy)} else {byURL[item.url] = item@@ -290,7 +293,8 @@ public struct BulkUninstallation: Sendable {isBeyondTheHelper: leftover.match.heldBack == .beyondTheHelper,isLeftForAnAdministrator: leftover.isLeftForAnAdministrator,removedElsewhere: uninstallation.removedElsewhere,- holdsDamagedSettings: leftover.holdsDamagedSettings+ holdsDamagedSettings: leftover.holdsDamagedSettings,+ syncedBy: leftover.syncedBy))}add(Item(diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGuard.swift b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGuard.swiftindex d31743ee..61050cb5 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGuard.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalGuard.swift@@ -3,7 +3,7 @@ import Foundationinternal import PeelPrivileged/// Why `RemovalGuard` refuses to move an item.-public enum GuardRefusal: String, Sendable, Hashable, CaseIterable {+public enum GuardRefusal: Sendable, Hashable, CaseIterable {/// The exclusions have not been read yet, or cannot be read, so nothing moves.case exclusionsNotKnown/// The person excluded it, or something inside it.@@ -16,7 +16,7 @@ public enum GuardRefusal: String, Sendable, Hashable, CaseIterable {case holdsProtectedData/// It syncs to the person's other devices, through iCloud or File Provider or in a folder another app keeps in/// step (`SyncedFolders`), as Desktop and Documents do in iCloud Drive.- case inTheCloud+ case inTheCloud(SyncKeeper)/// A sandboxed app's documents are inside.case holdsDocuments/// A photo, music, or video library is inside.@@ -26,6 +26,12 @@ public enum GuardRefusal: String, Sendable, Hashable, CaseIterable {/// macOS would not let Peel list a folder inside it, so whether something Peel never moves is there is not known.case couldNotLookInside+ /// Each kind of refusal once, the cloud standing for every keeper.+ public static let allCases: [GuardRefusal] = [+ .exclusionsNotKnown, .excluded, .staysItself, .protectedLocation, .holdsProtectedData, .inTheCloud(.cloud),+ .holdsDocuments, .holdsALibrary, .holdsWorkKeptInACache, .couldNotLookInside,+ ]+/// A fixed word for the reason, which the refusal log stores, so a record still reads in a later version.public var name: String {switch self {@@ -42,9 +48,19 @@ public enum GuardRefusal: String, Sendable, Hashable, CaseIterable {}}- public init?(name: String) {+ /// What a refusal log keeps beside the word, when the word alone doesn't say it all.+ var detail: String? {+ guard case .inTheCloud(let keeper) = self else { return nil }+ return keeper.detail+ }++ public init?(name: String, detail: String? = nil) {guard let refusal = Self.allCases.first(where: { $0.name == name }) else { return nil }- self = refusal+ if case .inTheCloud = refusal {+ self = .inTheCloud(SyncKeeper(detail: detail))+ } else {+ self = refusal+ }}}@@ -63,7 +79,7 @@ struct RemovalGuard: Sendable {private let protectedTrees: [[String]]private let protectedObjects: ProtectedObjectsprivate let exclusions: Exclusions- private let syncsToOtherDevices: @Sendable (URL) -> Bool+ private let syncKeeper: @Sendable (URL) -> SyncKeeper?var knowsTheExclusions: Bool { exclusions.isKnown }@@ -74,10 +90,10 @@ struct RemovalGuard: Sendable {init(environment: SearchEnvironment,exclusions: Exclusions = .none,- syncsToOtherDevices: @escaping @Sendable (URL) -> Bool = SyncedFolders().syncsToOtherDevices+ syncKeeper: @escaping @Sendable (URL) -> SyncKeeper? = SyncedFolders().keeper(of:)) {self.exclusions = exclusions- self.syncsToOtherDevices = syncsToOtherDevices+ self.syncKeeper = syncKeeperlet home = environment.homeDirectoryself.home = home.path(percentEncoded: false)var paths: [String] = [@@ -151,7 +167,8 @@ struct RemovalGuard: Sendable {let type = Self.type(of: item?.path(percentEncoded: false) ?? located)// The kernel's own name for the item is judged too: `/.vol/<device>/<inode>` names a file by its numbers// alone and shows none of the folders it sits in.- let names = Set([path, located, PathPattern.kernelName(of: path, followingLinks: false)].compactMap(\.self))+ let inOrder = [path, located, PathPattern.kernelName(of: path, followingLinks: false)].compactMap(\.self)+ let names = Set(inOrder)// Worked out once per name, since each resolves links on disk. The names are standardized already, so these// are the spellings the exclusions would work out themselves.let spelled = Dictionary(uniqueKeysWithValues: names.map { ($0, ProtectedData.spellings(of: $0)) })@@ -197,7 +214,10 @@ struct RemovalGuard: Sendable {let protectedFlags = UInt32(SF_RESTRICTED) | UInt32(SF_NOUNLINK)guard lstat(path, &info) != 0 || info.st_flags & protectedFlags == 0 else { return .protectedLocation }// Not for Put Back, which removes nothing from the other devices.- if item == nil, names.contains(where: { syncsToOtherDevices(URL(filePath: $0)) }) { return .inTheCloud }+ // Asked of the name as written first, so the marker is named the way the item was.+ if item == nil, let keeper = inOrder.lazy.compactMap({ syncKeeper(URL(filePath: $0)) }).first {+ return .inTheCloud(keeper)+ }// Last, since each reads what is a level or two inside the folder, and a name refused above needs none of it.guard !exclusions.isAnExcludedApp(item ?? URL(filePath: path)) else { return .excluded }diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swiftindex 0e611dfc..063eb16d 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift@@ -165,6 +165,7 @@ extension TrashFailure.Reason {public var detail: String? {switch self {+ case .guarded(let refusal): refusal?.detailcase .failed(let message): messagecase .somethingElseMoved(let name): namecase .heldOpen(let processes), .heldByAnotherAccount(let processes), .openForAnotherUser(let processes),@@ -176,7 +177,7 @@ extension TrashFailure.Reason {/// The reason a refusal log stored as `name` and `detail`, or nil for a word this version doesn't know.public init?(name: String, detail: String?) {- if let refusal = GuardRefusal(name: name) {+ if let refusal = GuardRefusal(name: name, detail: detail) {self = .guarded(refusal)return}diff --git a/Packages/PeelCore/Sources/PeelCore/Search/FileSearch.swift b/Packages/PeelCore/Sources/PeelCore/Search/FileSearch.swiftindex f55f578d..8532ceec 100644--- a/Packages/PeelCore/Sources/PeelCore/Search/FileSearch.swift+++ b/Packages/PeelCore/Sources/PeelCore/Search/FileSearch.swift@@ -73,6 +73,8 @@ public struct FileSearchResults: Sendable {public var isTruncated = false/// The files Spotlight found that the list leaves out, by why. A file the cut left out counts there, not here.public var leftOut: [FileSearch.LeftOut: Int] = [:]+ /// The apps that keep in step the folders of files left out because they sync, each marker once.+ public var syncedBy: [SyncKeeper] = []/// False when the query itself could not be made or run, which is not the same as finding nothing.public var didRun = true/// The disks Spotlight doesn't index, named as Finder names them, asked only when nothing was found.@@ -177,11 +179,11 @@ public enum FileSearch {environment: SearchEnvironment = .current,exclusions: Exclusions = .none,refusal: ((URL) -> GuardRefusal?)? = nil,- syncsToOtherDevices: (@Sendable (URL) -> Bool)? = nil+ syncKeeper: (@Sendable (URL) -> SyncKeeper?)? = nil) -> FileSearchResults {- let syncsToOtherDevices = syncsToOtherDevices ?? SyncedFolders().syncsToOtherDevices+ let syncKeeper = syncKeeper ?? SyncedFolders().keeper(of:)let refusal = refusal ?? RemovalGuard(- environment: environment, exclusions: exclusions, syncsToOtherDevices: syncsToOtherDevices+ environment: environment, exclusions: exclusions, syncKeeper: syncKeeper).refusal(of:)let appData = AppDataFolders(home: environment.homeDirectory)var results = FileSearchResults()@@ -207,15 +209,18 @@ public enum FileSearch {listing: for candidate in candidates {let url = URL(filePath: candidate.path)let hasRoom = results.files.count < maximumResults- let judgment = judge(- url, info: candidate.info, kind: kind, refusal: refusal, syncsToOtherDevices: syncsToOtherDevices- )+ let judgment = judge(url, info: candidate.info, kind: kind, refusal: refusal, syncKeeper: syncKeeper)switch judgment {case .skipped:continuecase .leftOut(let reason):// Counted only while the list had room: whatever came after was left out by the cut.- if hasRoom { results.leftOut[reason, default: 0] += 1 }+ guard hasRoom else { continue }+ results.leftOut[reason, default: 0] += 1+ if reason == .syncs, let keeper = syncKeeper(url), keeper != .cloud,+ !results.syncedBy.contains(keeper) {+ results.syncedBy.append(keeper)+ }case .listed:guard hasRoom else {results.isTruncated = true@@ -259,7 +264,7 @@ public enum FileSearch {}static func judge(- _ url: URL, info: stat, kind: FileKind, refusal: (URL) -> GuardRefusal?, syncsToOtherDevices: (URL) -> Bool+ _ url: URL, info: stat, kind: FileKind, refusal: (URL) -> GuardRefusal?, syncKeeper: (URL) -> SyncKeeper?) -> Judgment {guard holdsItsContentsHere(info) else {// A transport stream is a movie only by its first bytes, and reading a file that lives only in the cloud@@ -270,7 +275,8 @@ public enum FileSearch {guard let refused = refusal(url) else { return .listed }// That a file syncs is what the person needs to know, whatever else the guard says: a file in iCloud Drive// sits in a tree the guard protects.- return .leftOut(refused == .inTheCloud || syncsToOtherDevices(url) ? .syncs : LeftOut(refused))+ if case .inTheCloud = refused { return .leftOut(.syncs) }+ return .leftOut(syncKeeper(url) != nil ? .syncs : LeftOut(refused))}/// macOS gives TypeScript's `.ts` the type of an MPEG-2 transport stream, a movie, so such a file is one only whendiff --git a/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift b/Packages/PeelCore/Sources/PeelCore/Space/Installers.swiftindex a9f0143a..0ab178ea 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift@@ -35,6 +35,8 @@ public struct InstallerItem: Sendable, Hashable, Identifiable {/// Why the item is left for the person to choose, from what measuring it saw: it was not measured or not read,/// or a wallet or a repository is inside.public var heldBack: HoldBack?+ /// What keeps it in step with the other devices, when it is held back as `inTheCloud`.+ public var syncedBy: SyncKeeper? = nilpublic var id: URL { url }@@ -152,7 +154,7 @@ public enum Installers {minimumSize: Int64,measure: LeftoverScanner.Measure,canList: (URL) -> AccessState = FullDiskAccess.canList,- syncsToOtherDevices: (URL) -> Bool = SyncedFolders().syncsToOtherDevices,+ syncKeeper: (URL) -> SyncKeeper? = SyncedFolders().keeper(of:),openFiles: OpenFiles = OpenFiles()) async -> InstallerScan {var items: [InstallerItem] = []@@ -184,7 +186,7 @@ public enum Installers {let (size, seen, newestInside) = await measured(url, by: measure)guard isWorthARow(size, minimumSize) else { continue }let heldBack = heldBack(- url, seen: seen, in: folder, syncsToOtherDevices: syncsToOtherDevices, openFiles: openFiles+ url, seen: seen, in: folder, syncKeeper: syncKeeper, openFiles: openFiles)if isIncomplete {items.append(@@ -218,7 +220,7 @@ public enum Installers {exclusions: exclusions,minimumSize: minimumSize,measure: measure,- syncsToOtherDevices: syncsToOtherDevices,+ syncKeeper: syncKeeper,openFiles: openFiles)items += await firmwareFiles(home: home, exclusions: exclusions, minimumSize: minimumSize, measure: measure)@@ -228,7 +230,7 @@ public enum Installers {exclusions: exclusions,minimumSize: minimumSize,measure: measure,- syncsToOtherDevices: syncsToOtherDevices,+ syncKeeper: syncKeeper,openFiles: openFiles)items += await packagesKeptByApps(@@ -237,7 +239,7 @@ public enum Installers {exclusions: exclusions,minimumSize: minimumSize,measure: measure,- syncsToOtherDevices: syncsToOtherDevices,+ syncKeeper: syncKeeper,openFiles: openFiles)@@ -250,10 +252,11 @@ public enum Installers {if readable == .missing { unreadable.append(backupFolder) }let reach = HelperReach(environment: SearchEnvironment(homeDirectory: home, rootDirectory: root))items = items.map { item in+ var item = item+ if item.heldBack == .inTheCloud { item.syncedBy = syncKeeper(item.url) }guard item.requiresPrivileges, item.heldBack?.cannotBeMoved != true, reach.isBeyond(item.url) else {return item}- var item = itemitem.heldBack = .beyondTheHelperreturn item}@@ -286,9 +289,9 @@ public enum Installers {/// Why an item is left for the person to choose: it syncs to other devices, measuring it saw a reason, a program/// has it open, or it belongs to every account on this Mac.private static func heldBack(- _ url: URL, seen: HoldBack?, in folder: Folder, syncsToOtherDevices: (URL) -> Bool, openFiles: OpenFiles+ _ url: URL, seen: HoldBack?, in folder: Folder, syncKeeper: (URL) -> SyncKeeper?, openFiles: OpenFiles) -> HoldBack? {- if syncsToOtherDevices(url) { return .inTheCloud }+ if syncKeeper(url) != nil { return .inTheCloud }if let seen { return seen }if openFiles.isAttachedDiskImage(url) { return .attachedDiskImage }if !openFiles.holders(of: url).isEmpty { return .openInAProgram }@@ -460,7 +463,7 @@ public enum Installers {exclusions: Exclusions,minimumSize: Int64,measure: LeftoverScanner.Measure,- syncsToOtherDevices: (URL) -> Bool,+ syncKeeper: (URL) -> SyncKeeper?,openFiles: OpenFiles) async -> [InstallerItem] {var items: [InstallerItem] = []@@ -484,7 +487,7 @@ public enum Installers {notes: version.map { [.version($0)] } ?? [],requiresPrivileges: FileAccess.requiresPrivilegesToRemove(url),heldBack: heldBack(- url, seen: seen, in: folder, syncsToOtherDevices: syncsToOtherDevices, openFiles: openFiles+ url, seen: seen, in: folder, syncKeeper: syncKeeper, openFiles: openFiles)))}@@ -529,7 +532,7 @@ public enum Installers {exclusions: Exclusions,minimumSize: Int64,measure: LeftoverScanner.Measure,- syncsToOtherDevices: (URL) -> Bool,+ syncKeeper: (URL) -> SyncKeeper?,openFiles: OpenFiles) async -> [InstallerItem] {let caches = home.appending(path: "Library/Caches", directoryHint: .isDirectory)@@ -594,7 +597,7 @@ public enum Installers {notes: app.map { [.downloadedBy($0.name)] } ?? [],requiresPrivileges: FileAccess.requiresPrivilegesToRemove(url),heldBack: heldBack(- url, seen: seen, in: place, syncsToOtherDevices: syncsToOtherDevices, openFiles: openFiles+ url, seen: seen, in: place, syncKeeper: syncKeeper, openFiles: openFiles)?? (isRunning ? .appIsRunning : nil)))@@ -610,7 +613,7 @@ public enum Installers {exclusions: Exclusions,minimumSize: Int64,measure: LeftoverScanner.Measure,- syncsToOtherDevices: (URL) -> Bool,+ syncKeeper: (URL) -> SyncKeeper?,openFiles: OpenFiles) async -> [InstallerItem] {let support = home.appending(path: "Library/Application Support", directoryHint: .isDirectory)@@ -632,7 +635,7 @@ public enum Installers {guard isWorthARow(size, minimumSize) else { continue }let place = Folder(url: folder, isSharedWithEveryone: false)let heldBack = heldBack(- url, seen: seen, in: place, syncsToOtherDevices: syncsToOtherDevices, openFiles: openFiles+ url, seen: seen, in: place, syncKeeper: syncKeeper, openFiles: openFiles)let named = installedApp(for: url, in: installedApps) == nil ? owner : nilitems.append(appInstaller(diff --git a/Packages/PeelCore/Sources/PeelCore/Support/SyncedFolders.swift b/Packages/PeelCore/Sources/PeelCore/Support/SyncedFolders.swiftindex 6bbbce01..d622f948 100644--- a/Packages/PeelCore/Sources/PeelCore/Support/SyncedFolders.swift+++ b/Packages/PeelCore/Sources/PeelCore/Support/SyncedFolders.swift@@ -1,35 +1,91 @@import Darwin-import Foundation+public import Foundationinternal import PeelPrivilegedimport Synchronization-/// What syncs to the person's other devices, where moving it to the Trash would remove it there too: what iCloud and-/// File Provider keep (`isUbiquitousItem`), and what sits in a folder another app keeps in step, known by the entry-/// the app writes at that folder's root. Each folder is asked once for the life of an instance.-final class SyncedFolders: Sendable {- /// The entry each app keeps at the root of a folder it syncs: Syncthing's folder marker (`.stfolder`, its default+/// What keeps an item in step with the person's other devices.+public enum SyncKeeper: Sendable, Hashable {+ /// iCloud or a cloud app through File Provider.+ case cloud+ /// An app that syncs the folder holding `marker`, the entry the app keeps at that folder's root.+ case app(SyncApp, marker: URL)++ /// The keeper as text, which a refusal log stores beside the refusal. Nil for `cloud`, which says no more than the+ /// refusal's own word.+ var detail: String? {+ guard case .app(let app, let marker) = self else { return nil }+ return app.rawValue + "\n" + marker.path(percentEncoded: false)+ }++ /// The keeper a refusal log stored as `detail`. A record that names no app is `cloud`, as every record did before+ /// the app was kept.+ init(detail: String?) {+ let parts = detail?.split(separator: "\n", maxSplits: 1).map(String.init) ?? []+ guard parts.count == 2, let app = SyncApp(rawValue: parts[0]), parts[1].hasPrefix("/") else {+ self = .cloud+ return+ }+ self = .app(app, marker: URL(filePath: parts[1]))+ }+}++/// An app that keeps a folder in step with other devices, known by the entry it writes at that folder's root.+public enum SyncApp: String, Sendable, Hashable, CaseIterable {+ case syncthing+ case resilioSync+ case synologyDrive+ case mega+ case dropbox++ /// The app's name, as its maker writes it.+ public var name: String {+ switch self {+ case .syncthing: "Syncthing"+ case .resilioSync: "Resilio Sync"+ case .synologyDrive: "Synology Drive Client"+ case .mega: "MEGA"+ case .dropbox: "Dropbox"+ }+ }++ /// The entry the app keeps at the root of a folder it syncs: Syncthing's folder marker (`.stfolder`, its default/// `markerName`), the share's identifier in Resilio Sync's `.sync` folder, Synology Drive Client's working folder,/// the ignore file MEGA writes in every new sync (`src/sync.cpp` in meganz/sdk), and the cache Dropbox keeps in/// its folder when it doesn't sync through File Provider (Dropbox's "How to clear the Dropbox cache folder").- static let markers = [".stfolder", ".sync/ID", ".SynologyWorkingDirectory", ".megaignore", ".dropbox.cache"]+ var marker: String {+ switch self {+ case .syncthing: ".stfolder"+ case .resilioSync: ".sync/ID"+ case .synologyDrive: ".SynologyWorkingDirectory"+ case .mega: ".megaignore"+ case .dropbox: ".dropbox.cache"+ }+ }+}- private let answers = Mutex<[String: Bool]>([:])+/// What syncs to the person's other devices, where moving it to the Trash would remove it there too: what iCloud and+/// File Provider keep (`isUbiquitousItem`), and what sits in a folder another app keeps in step, known by the entry+/// the app writes at that folder's root. Each folder is asked once for the life of an instance.+final class SyncedFolders: Sendable {+ private let answers = Mutex<[String: SyncKeeper?]>([:])func syncsToOtherDevices(_ url: URL) -> Bool {- url.isInTheCloud || isKeptInStep(url)+ keeper(of: url) != nil}- /// Whether `url`, when it is a folder, or a folder it sits in holds one of the markers.- func isKeptInStep(_ url: URL) -> Bool {+ /// What keeps `url` in step: iCloud or File Provider, or else the app whose marker is in the nearest folder at or+ /// above it. Nil when nothing does.+ func keeper(of url: URL) -> SyncKeeper? {+ if url.isInTheCloud { return .cloud }let names = PathComponents.of(url.path(percentEncoded: false))- return isKeptInStep(folder: FileAccess.isARealFolder(url) ? names[...] : names.dropLast())+ return keeper(ofFolder: FileAccess.isARealFolder(url) ? names[...] : names.dropLast())}/// Whether the folder whose entries are `entries` holds one of the markers, read from a listing already made.static func marksAFolder(_ entries: [URL]) -> Bool {entries.contains { entry in- markers.contains { marker in- let parts = marker.split(separator: "/", maxSplits: 1).map(String.init)+ SyncApp.allCases.contains { app in+ let parts = app.marker.split(separator: "/", maxSplits: 1).map(String.init)guard entry.lastPathComponent == parts[0] else { return false }var info = stat()return parts.count == 1 || lstat(entry.path(percentEncoded: false) + "/" + parts[1], &info) == 0@@ -37,15 +93,16 @@ final class SyncedFolders: Sendable {}}- /// The answer for the folder named by `names`, kept with what the folders above it answered.- private func isKeptInStep(folder names: ArraySlice<String>) -> Bool {- guard !names.isEmpty else { return false }+ /// The keeper for the folder named by `names`, kept with what the folders above it answered.+ private func keeper(ofFolder names: ArraySlice<String>) -> SyncKeeper? {+ guard !names.isEmpty else { return nil }let folder = "/" + names.joined(separator: "/")if let known = answers.withLock({ $0[folder] }) { return known }var info = stat()- let kept = Self.markers.contains { lstat(folder + "/" + $0, &info) == 0 }- || isKeptInStep(folder: names.dropLast())- answers.withLock { $0[folder] = kept }- return kept+ let keeper = SyncApp.allCases.first { lstat(folder + "/" + $0.marker, &info) == 0 }+ .map { SyncKeeper.app($0, marker: URL(filePath: folder + "/" + $0.marker)) }+ ?? keeper(ofFolder: names.dropLast())+ answers.withLock { $0[folder] = keeper }+ return keeper}}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AttackRemovalGuardTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AttackRemovalGuardTests.swiftindex c40b1531..4e0bc540 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/AttackRemovalGuardTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/AttackRemovalGuardTests.swift@@ -670,13 +670,13 @@ struct AttackRemovalGuardTests {let synced: Set = ["Report.pdf", "Trip", "Notes.txt"]let guardian = RemovalGuard(environment: SearchEnvironment(homeDirectory: home, rootDirectory: directory.url.appending(path: "root")),- syncsToOtherDevices: { synced.contains($0.lastPathComponent) }+ syncKeeper: { synced.contains($0.lastPathComponent) ? .cloud : nil })let (device, number) = try #require(inode(file.path(percentEncoded: false)))- #expect(guardian.refusal(of: file) == .inTheCloud)- #expect(guardian.refusal(of: folder) == .inTheCloud)- #expect(guardian.refusal(of: URL(filePath: "/.vol/\(device)/\(number)")) == .inTheCloud, "asked by its numbers")+ #expect(guardian.refusal(of: file) == .inTheCloud(.cloud))+ #expect(guardian.refusal(of: folder) == .inTheCloud(.cloud))+ #expect(guardian.refusal(of: URL(filePath: "/.vol/\(device)/\(number)")) == .inTheCloud(.cloud), "asked by its numbers")#expect(guardian.refusal(of: local) == nil)#expect(guardian.refusal(ofPuttingBack: trashed, at: home.appending(path: "Desktop/Notes.txt")) == nil)}@@ -693,9 +693,11 @@ struct AttackRemovalGuardTests {environment: SearchEnvironment(homeDirectory: home, rootDirectory: directory.url.appending(path: "root")))- #expect(guardian.refusal(of: file) == .inTheCloud)- #expect(guardian.refusal(of: file.deletingLastPathComponent()) == .inTheCloud)- #expect(guardian.refusal(of: home.appending(path: "Sync", directoryHint: .isDirectory)) == .inTheCloud)+ let syncthing = GuardRefusal.inTheCloud(.app(.syncthing, marker: home.appending(path: "Sync/.stfolder")))++ #expect(guardian.refusal(of: file) == syncthing)+ #expect(guardian.refusal(of: file.deletingLastPathComponent()) == syncthing)+ #expect(guardian.refusal(of: home.appending(path: "Sync", directoryHint: .isDirectory)) == syncthing)#expect(guardian.refusal(of: twin) == nil)#expect(guardian.refusal(ofPuttingBack: trashed, at: file.deletingLastPathComponent().appending(path: "Shells.jpg")) == nil)}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/DuplicateFinderTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/DuplicateFinderTests.swiftindex ee994af6..167d3fab 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/DuplicateFinderTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/DuplicateFinderTests.swift@@ -161,11 +161,11 @@ struct DuplicateFinderTests {asked.append(url.lastPathComponent)switch url.lastPathComponent {case "refused", "partner": return .protectedLocation- case "synced": return .inTheCloud+ case "synced": return .inTheCloud(.cloud)default: return nil}},- syncsToOtherDevices: { $0.lastPathComponent == "synced" }+ syncKeeper: { $0.lastPathComponent == "synced" ? .cloud : nil })#expect(asked == ["a", "b", "refused", "linked", "other", "alone", "partner", "synced", "twin"])@@ -449,6 +449,8 @@ struct DuplicateFinderTests {#expect(group.movableFiles.isEmpty)#expect(group.reclaimableSize == 0)#expect(scan.suggestedSelection.isEmpty)+ let syncthing = SyncKeeper.app(.syncthing, marker: directory.url.appending(path: "home/.stfolder"))+ #expect(group.files.map { $0.syncedBy?.resolved } == [syncthing.resolved, syncthing.resolved])}/// A chosen folder that is not there, as a folder on a disk that isn't connected, is named rather than passed over.diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swiftindex 41f10446..082b296c 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileCommandTests.swift@@ -717,6 +717,23 @@ struct FileCommandTests {})}+ @Test func namesTheAppThatSyncsTheCopiesItLeavesAlone() async throws {+ let directory = try TemporaryDirectory()+ let contents = Data((0..<3_000).map { _ in UInt8.random(in: 0...255) })+ try directory.directory("home/.stfolder")+ try directory.file("home/Desktop/a.bin", contents: contents)+ try directory.file("home/Documents/a.bin", contents: contents)+ let home = directory.url.appending(path: "home", directoryHint: .isDirectory)+ let scan = try await DuplicateFinder(homeDirectory: home).scan(+ .everySize(in: ["Desktop", "Documents"].map { home.appending(path: $0, directoryHint: .isDirectory) })+ )+ let marker = Output.path(home.appending(path: ".stfolder"))++ #expect(DuplicatesCommand.notes(for: scan).contains(+ "Syncthing syncs some of them to your other devices (its marker is \(marker))."+ ))+ }+@Test func refusesEachFolderItCantScanWithItsReason() throws {let finder = "/System/Library/CoreServices/Finder.app"let error = #expect(throws: (any Error).self) {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileSearchTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileSearchTests.swiftindex 667205b1..c8dac6c4 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/FileSearchTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileSearchTests.swift@@ -193,7 +193,9 @@ struct FileSearchTests {let synced = try directory.file("home/Documents/Report.pdf", bytes: 9_000)let local = try directory.file("home/Downloads/Setup.dmg", bytes: 1_000)let environment = SearchEnvironment(homeDirectory: home, rootDirectory: directory.url)- let guardian = RemovalGuard(environment: environment, syncsToOtherDevices: { $0.lastPathComponent == "Report.pdf" })+ let guardian = RemovalGuard(+ environment: environment, syncKeeper: { $0.lastPathComponent == "Report.pdf" ? .cloud : nil }+ )let results = FileSearch.results(from: [synced, local].map { $0.path(percentEncoded: false) },@@ -205,6 +207,23 @@ struct FileSearchTests {#expect(results.leftOut == [.syncs: 1])}+ @Test func namesTheAppThatSyncsWhatItLeftOut() throws {+ let directory = try TemporaryDirectory()+ let home = directory.url.appending(path: "home", directoryHint: .isDirectory)+ try directory.file("home/Sync/.megaignore")+ let synced = try directory.file("home/Sync/Report.pdf")+ let local = try directory.file("home/Desktop/Setup.dmg")++ let results = FileSearch.results(+ from: [synced, local].map { $0.path(percentEncoded: false) },+ environment: SearchEnvironment(homeDirectory: home, rootDirectory: directory.url)+ )++ #expect(results.files.map(\.url.lastPathComponent) == ["Setup.dmg"])+ #expect(results.leftOut == [.syncs: 1])+ #expect(results.syncedBy == [.app(.mega, marker: directory.url.appending(path: "home/Sync/.megaignore"))])+ }+@Test func aRefusedFileThatSyncsIsCountedAsSyncing() throws {let directory = try TemporaryDirectory()let home = directory.url.appending(path: "home", directoryHint: .isDirectory)@@ -214,7 +233,7 @@ struct FileSearchTests {let results = FileSearch.results(from: [inICloudDrive, keychain].map { $0.path(percentEncoded: false) },environment: SearchEnvironment(homeDirectory: home, rootDirectory: directory.url),- syncsToOtherDevices: { $0.lastPathComponent == "Report.pdf" }+ syncKeeper: { $0.lastPathComponent == "Report.pdf" ? .cloud : nil })#expect(results.files.isEmpty)@@ -230,7 +249,7 @@ struct FileSearchTests {info.st_mode = S_IFREGinfo.st_flags = UInt32(SF_DATALESS)func judged(_ kind: FileKind) -> FileSearch.Judgment {- FileSearch.judge(clip, info: info, kind: kind, refusal: { _ in nil }, syncsToOtherDevices: { _ in false })+ FileSearch.judge(clip, info: info, kind: kind, refusal: { _ in nil }, syncKeeper: { _ in nil })}#expect(judged(.any) == .leftOut(.syncs))@@ -317,7 +336,7 @@ struct FileSearchTests {from: paths + [bigRefused, smallRefused, last].map { $0.path(percentEncoded: false) },environment: SearchEnvironment(homeDirectory: home, rootDirectory: directory.url),refusal: { $0.lastPathComponent.hasPrefix("refused") ? .protectedLocation : nil },- syncsToOtherDevices: { _ in false }+ syncKeeper: { _ in nil })#expect(results.files.count == FileSearch.maximumResults)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swiftindex bdf5b976..d6c0de28 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift@@ -374,7 +374,7 @@ struct InstallersTests {let scan = await Installers.scan(installedApps: [], home: directory.url, root: directory.url, exclusions: .none, minimumSize: 100_000,measure: LeftoverScanner.walk,- syncsToOtherDevices: { PathPattern.comparablePath(of: $0.deletingLastPathComponent()) == documents }+ syncKeeper: { PathPattern.comparablePath(of: $0.deletingLastPathComponent()) == documents ? .cloud : nil })let heldBack = Dictionary(uniqueKeysWithValues: scan.items.map { ($0.name, $0.heldBack) })@@ -386,6 +386,22 @@ struct InstallersTests {}+ @Test func namesTheAppThatSyncsAnInstallerItLeavesAlone() async throws {+ let directory = try TemporaryDirectory()+ try directory.file("Documents/.megaignore")+ try directory.file("Documents/Tool-2.dmg", bytes: 400_000)++ let scan = await Installers.scan(+ installedApps: [], home: directory.url, root: directory.url, exclusions: .none, minimumSize: 100_000,+ measure: LeftoverScanner.walk+ )++ let item = try #require(scan.items.first { $0.name == "Tool-2.dmg" })+ #expect(item.heldBack == .inTheCloud)+ let mega = SyncKeeper.app(.mega, marker: directory.url.appending(path: "Documents/.megaignore"))+ #expect(item.syncedBy?.resolved == mega.resolved)+ }+@Test func countsToRemoveOnlyWhatCanMove() {func item(_ name: String,diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swiftindex 00d87499..70ee6b93 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift@@ -1315,7 +1315,7 @@ struct LeftoverScannerTests {parent: ParentAccess(url.deletingLastPathComponent()),home: directory.url.appending(path: "home").path(percentEncoded: false),root: directory.url.appending(path: "root").path(percentEncoded: false),- syncsToOtherDevices: { $0.lastPathComponent == "Example" }+ syncKeeper: { $0.lastPathComponent == "Example" ? .cloud : nil })}@@ -1341,8 +1341,12 @@ struct LeftoverScannerTests {)}+ let mega = SyncKeeper.app(.mega, marker: directory.url.appending(path: "home/Projects/.megaignore"))+#expect(await leftover(synced).match.heldBack == .inTheCloud)+ #expect(await leftover(synced).syncedBy == mega)#expect(await leftover(local).match.heldBack == nil)+ #expect(await leftover(local).syncedBy == nil)}/// A browser's folder that holds a profile with a wallet extension cannot be selected either.diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swiftindex 9d6e9332..13db0139 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift@@ -1385,7 +1385,7 @@ struct ProjectArtifactsTests {#expect(ProjectArtifacts.refusal(for: home, home: home) == .tooBroad)#expect(ProjectArtifacts.refusal(for: URL(filePath: "/Volumes/Disk"), home: home) == .tooBroad)- #expect(ProjectArtifacts.refusal(for: home.appending(path: "Library/Mobile Documents/com~apple~CloudDocs/Code"), home: home) == .inTheCloud)+ #expect(ProjectArtifacts.refusal(for: home.appending(path: "Library/Mobile Documents/com~apple~CloudDocs/Code"), home: home) == .inTheCloud(.cloud))#expect(ProjectArtifacts.refusal(for: directory.url.appending(path: "nothing-here"), home: home) == .notAFolder)#expect(ProjectArtifacts.refusal(for: try directory.directory("Code"), home: home) == nil)@@ -1393,7 +1393,7 @@ struct ProjectArtifactsTests {#expect(ProjectArtifacts.refusal(for: URL(filePath: "/users/x"), home: home) == .tooBroad)#expect(ProjectArtifacts.refusal(for: URL(filePath: "/System/Volumes/Data/Users/x"), home: home) == .tooBroad)#expect(ProjectArtifacts.refusal(for: URL(filePath: "/System/Volumes/Data"), home: home) == .tooBroad)- #expect(ProjectArtifacts.refusal(for: home.appending(path: "Library/CLOUDSTORAGE/Dropbox"), home: home) == .inTheCloud)+ #expect(ProjectArtifacts.refusal(for: home.appending(path: "Library/CLOUDSTORAGE/Dropbox"), home: home) == .inTheCloud(.cloud))}/// A cloud folder is known by its place, never by a name that only begins like one. What is inside an app or@@ -1448,8 +1448,8 @@ struct ProjectArtifactsTests {@Test func refusesRootsThatAreTooBroadOrNotOurs() {#expect(ProjectArtifacts.refusal(for: URL(filePath: "/")) == .tooBroad)#expect(ProjectArtifacts.refusal(for: URL(filePath: "/Users")) == .systemFolder)- #expect(ProjectArtifacts.refusal(for: URL(filePath: "/Users/x/Library/Mobile Documents/com~apple~Pages")) == .inTheCloud)- #expect(ProjectArtifacts.refusal(for: URL(filePath: "/Users/x/Library/CloudStorage/Dropbox")) == .inTheCloud)+ #expect(ProjectArtifacts.refusal(for: URL(filePath: "/Users/x/Library/Mobile Documents/com~apple~Pages")) == .inTheCloud(.cloud))+ #expect(ProjectArtifacts.refusal(for: URL(filePath: "/Users/x/Library/CloudStorage/Dropbox")) == .inTheCloud(.cloud))#expect(ProjectArtifacts.refusal(for: URL(filePath: "/Users/x/does-not-exist")) == .notAFolder)}@@ -1468,7 +1468,8 @@ struct ProjectArtifactsTests {let scan = await ProjectArtifacts.scan(roots: [code, shared])#expect(scan.artifacts.map(\.project.lastPathComponent) == ["kept"])- #expect(scan.refusedRoots.map { $0.reason } == [.inTheCloud])+ let mega = SyncKeeper.app(.mega, marker: directory.url.appending(path: "Shared/.megaignore"))+ #expect(scan.refusedRoots.map { $0.reason } == [.inTheCloud(mega)])}@Test func findsEveryKindItKnowsInAProjectOfItsOwn() async throws {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/RefusalLogTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/RefusalLogTests.swiftindex 5dad30cd..c35a1693 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/RefusalLogTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/RefusalLogTests.swift@@ -92,6 +92,22 @@ struct RefusalLogTests {#expect(isInHistory.withLock { $0 }, "History waited for the refusals")}+ @Test func keepsWhichAppSyncsWhatItRefused() async throws {+ let directory = try TemporaryDirectory()+ let log = RefusalLog(url: directory.url.appending(path: "Peel/refusals.json"))+ let syncthing = GuardRefusal.inTheCloud(.app(.syncthing, marker: URL(filePath: "/Users/me/.stfolder")))++ await log.add(+ [failure("/Users/me/Documents/a.pdf", .guarded(syncthing)), failure("/Users/me/b.pdf", .guarded(.inTheCloud(.cloud)))],+ source: "Duplicates", tool: "duplicates"+ )++ let records = try #require(await log.load().records)+ #expect(records.map { TrashFailure.Reason(name: $0.reason, detail: $0.detail) } == [+ .guarded(syncthing), .guarded(.inTheCloud(.cloud)),+ ])+ }+@Test func nothingIsWrittenWhenNothingWasRefused() async throws {let directory = try TemporaryDirectory()let url = directory.url.appending(path: "Peel/refusals.json")diff --git a/Packages/PeelCore/Tests/PeelCoreTests/SyncedFoldersTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/SyncedFoldersTests.swiftindex 6489bf55..fc46a342 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/SyncedFoldersTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/SyncedFoldersTests.swift@@ -29,6 +29,38 @@ struct SyncedFoldersTests {#expect(!synced.syncsToOtherDevices(directory.url.appending(path: "home/Plain/Projects/notes.txt")))}+ @Test func namesTheAppThatKeepsAFolderInStepAndItsMarker() throws {+ let directory = try TemporaryDirectory()+ try directory.directory("home/.stfolder")+ try directory.file("home/Documents/notes.txt")+ try directory.file("home/Music/.megaignore")+ try directory.file("home/Music/Live/set.txt")+ try directory.file("home/Sync/.sync/ID")+ try directory.file("home/Sync/notes.txt")+ let synced = SyncedFolders()+ func keeper(_ path: String) -> (SyncApp, String)? {+ guard case .app(let app, let marker) = synced.keeper(of: directory.url.appending(path: path)) else {+ return nil+ }+ return (app, marker.path(percentEncoded: false))+ }+ let home = directory.url.appending(path: "home").path(percentEncoded: false)++ #expect(keeper("home/Documents/notes.txt")! == (.syncthing, home + "/.stfolder"))+ #expect(keeper("home/Music/Live/set.txt")! == (.mega, home + "/Music/.megaignore"))+ #expect(keeper("home/Sync/notes.txt")! == (.resilioSync, home + "/Sync/.sync/ID"))+ #expect(synced.keeper(of: directory.url.appending(path: "notes.txt")) == nil)+ }++ @Test func aRefusalLogReadsBackTheAppAndItsMarker() {+ let keeper = SyncKeeper.app(.dropbox, marker: URL(filePath: "/Users/me/Dropbox/.dropbox.cache"))++ #expect(SyncKeeper(detail: keeper.detail) == keeper)+ #expect(SyncKeeper.cloud.detail == nil)+ #expect(SyncKeeper(detail: nil) == .cloud)+ #expect(SyncKeeper(detail: "rsync\n/Users/me/.stfolder") == .cloud)+ }+@Test func aSyncFolderWithoutResiliosIdentifierMarksNothing() throws {let directory = try TemporaryDirectory()try directory.file("Tool/.sync/settings.json")@@ -53,3 +85,11 @@ struct SyncedFoldersTests {#expect(!SyncedFolders.marksAFolder([URL(filePath: "/Sync/notes.txt")]))}}++extension SyncKeeper {+ /// The keeper with its marker's links resolved, since a folder's listing names `/var` as `/private/var`.+ var resolved: SyncKeeper {+ guard case .app(let app, let marker) = self else { return self }+ return .app(app, marker: URL(filePath: PathPattern.comparablePath(of: marker.resolvingSymlinksInPath())))+ }+}diff --git a/Peel/Views/AppDetailView.swift b/Peel/Views/AppDetailView.swiftindex 202d076c..e4ec6e1d 100644--- a/Peel/Views/AppDetailView.swift+++ b/Peel/Views/AppDetailView.swift@@ -422,7 +422,7 @@ struct AppDetailView: View {lines.append(String(localized: "Also used by \(users.formatted(.list(type: .and)))."))}if let heldBack = leftover.match.heldBack {- lines.append(String(localized: heldBack.explanation))+ lines.append(String(localized: heldBack.explanation(keptInStepBy: leftover.syncedBy)))}if leftover.holdsDamagedSettings {lines.append(String(localized: "Can’t be read as a property list, so nothing can read these settings."))diff --git a/Peel/Views/Duplicates/DuplicateGroupView.swift b/Peel/Views/Duplicates/DuplicateGroupView.swiftindex 8f51dd5d..64ecee3f 100644--- a/Peel/Views/Duplicates/DuplicateGroupView.swift+++ b/Peel/Views/Duplicates/DuplicateGroupView.swift@@ -140,8 +140,8 @@ private struct DuplicateFileRow: View {item}.accessibilityElement(children: .combine)- .accessibilityHint(Text(heldBack.explanation))- .help(Text(heldBack.explanation))+ .accessibilityHint(Text(heldBack.explanation(keptInStepBy: file.syncedBy)))+ .help(Text(heldBack.explanation(keptInStepBy: file.syncedBy)))// Where the copy is matters more than a look at it: what is done with it is done in Finder or on// another device. The folder symbol, the menu's for Show in Finder, is close to the eye's width, sodiff --git a/Peel/Views/FileSearch/FileSearchList.swift b/Peel/Views/FileSearch/FileSearchList.swiftindex 6e6f65d0..6a4bfc76 100644--- a/Peel/Views/FileSearch/FileSearchList.swift+++ b/Peel/Views/FileSearch/FileSearchList.swift@@ -34,7 +34,7 @@ struct FileSearchList: View {}if let results = search.results, !results.files.isEmpty, !results.leftOut.isEmpty {Label {- LeftOutLines(leftOut: results.leftOut, alignment: .leading)+ LeftOutLines(leftOut: results.leftOut, syncedBy: results.syncedBy, alignment: .leading)} icon: {Image(systemName: "eye.slash")}@@ -122,7 +122,7 @@ struct FileSearchList: View {Label("All Results Left Out", systemImage: "eye.slash")} description: {VStack(spacing: 8) {- LeftOutLines(leftOut: results.leftOut)+ LeftOutLines(leftOut: results.leftOut, syncedBy: results.syncedBy)if !results.unindexedDisks.isEmpty {Text("Spotlight isn’t indexing \(disks), so File Search can’t find anything there.")}@@ -244,12 +244,20 @@ struct FileSearchList: View {private struct LeftOutLines: View {let leftOut: [FileSearch.LeftOut: Int]+ var syncedBy: [SyncKeeper] = []var alignment = HorizontalAlignment.centervar body: some View {VStack(alignment: alignment, spacing: 6) {ForEach(FileSearch.LeftOut.allCases.filter { leftOut[$0] != nil }, id: \.self) { reason inline(for: reason, count: leftOut[reason] ?? 0)+ if reason == .syncs {+ ForEach(syncedBy, id: \.self) { keeper in+ if case .app(let app, let marker) = keeper {+ Text("\(app.name) syncs some of them to your other devices (its marker is \(marker.abbreviatedPath)).")+ }+ }+ }}}}diff --git a/Peel/Views/Installers/InstallerDetailView.swift b/Peel/Views/Installers/InstallerDetailView.swiftindex a7a94e12..53762618 100644--- a/Peel/Views/Installers/InstallerDetailView.swift+++ b/Peel/Views/Installers/InstallerDetailView.swift@@ -30,7 +30,9 @@ struct InstallerDetailView: View {url: item.url,icon: .file(item.url),detail: detail(for: item),- warning: item.heldBack.map { String(localized: $0.explanation) },+ warning: item.heldBack.map {+ String(localized: $0.explanation(keptInStepBy: item.syncedBy))+ },size: item.size ?? 0,isMeasured: item.size != nil,isLocked: item.isLocked(canUseHelper: helper.canAct),diff --git a/Peel/Views/MultipleAppsView.swift b/Peel/Views/MultipleAppsView.swiftindex edad16c0..03344d63 100644--- a/Peel/Views/MultipleAppsView.swift+++ b/Peel/Views/MultipleAppsView.swift@@ -269,7 +269,7 @@ struct MultipleAppsView: View {lines.append(String(localized: "Also used by \(users.formatted(.list(type: .and)))."))}if let heldBack = item.match?.heldBack {- lines.append(String(localized: heldBack.explanation))+ lines.append(String(localized: heldBack.explanation(keptInStepBy: item.syncedBy)))}if item.holdsDamagedSettings {lines.append(String(localized: "Can’t be read as a property list, so nothing can read these settings."))diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex c0c78a34..1bbee0fe 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -150,7 +150,9 @@ extension GuardRefusal {case .staysItself: "Peel won’t move this folder itself, since macOS expects to find it. What is inside it can go."case .protectedLocation: "Peel won’t move this: it is part of macOS, or inside something Peel protects."case .holdsProtectedData: "Peel won’t move this: something Peel protects is inside, such as a keychain or a wallet."- case .inTheCloud: "Peel won’t move this: it syncs to your other devices through iCloud or another app, and moving it to the Trash would also remove it from them."+ case .inTheCloud(.cloud): "Peel won’t move this: it syncs to your other devices through iCloud or another app, and moving it to the Trash would also remove it from them."+ case .inTheCloud(.app(let app, let marker)):+ "Peel won’t move this: it is in a folder \(app.name) syncs to your other devices (its marker is \(marker.abbreviatedPath)), and moving it to the Trash would also remove it from them."case .holdsDocuments: "Peel won’t move this: an app’s documents are inside."case .holdsALibrary: "Peel won’t move this: a photo, music, or video library is inside."case .holdsWorkKeptInACache: "Peel won’t move this: an app keeps work inside that exists nowhere else, such as an editor’s local history."@@ -227,7 +229,9 @@ extension ProjectArtifacts.Refusal {switch self {case .tooBroad: String(localized: "A whole home folder or disk is too much to search. Choose the folder your projects are in.")case .systemFolder: String(localized: "It is a folder that macOS or every account uses, not a folder of projects. Choose the folder your projects are in.")- case .inTheCloud: String(localized: "It is in a folder that syncs to your other devices through iCloud or another app, which Peel leaves to that app.")+ case .inTheCloud(.cloud): String(localized: "It is in a folder that syncs to your other devices through iCloud or another app, which Peel leaves to that app.")+ case .inTheCloud(.app(let app, let marker)):+ String(localized: "It is in a folder \(app.name) syncs to your other devices (its marker is \(marker.abbreviatedPath)), which Peel leaves to that app.")case .notAFolder: String(localized: "It isn’t a folder Peel can reach. A disk that isn’t connected looks like this too.")case .inAPackage: String(localized: "It is an app or another package, or inside one, and what is inside belongs to it.")case .neverSearched: String(localized: "It is a hidden folder, a Library, or a folder a tool fills, such as node_modules, or it sits inside one. Apps and tools keep what they install there, so Peel doesn’t look for projects in it.")@@ -443,6 +447,12 @@ extension HoldBack {"Not selected: an encrypted disk image holds what you put in it."}}++ /// The explanation, naming the app that keeps the item in step and its marker when one does.+ func explanation(keptInStepBy keeper: SyncKeeper?) -> LocalizedStringResource {+ guard self == .inTheCloud, case .app(let app, let marker)? = keeper else { return explanation }+ return "Left alone: this is in a folder \(app.name) syncs to your other devices (its marker is \(marker.abbreviatedPath)), and moving it to the Trash would also remove it from them."+ }}extension OrphanConfidence {diff --git a/PeelTests/RemovalFailureAlertTests.swift b/PeelTests/RemovalFailureAlertTests.swiftindex bb7efe69..ab474df6 100644--- a/PeelTests/RemovalFailureAlertTests.swift+++ b/PeelTests/RemovalFailureAlertTests.swift@@ -26,6 +26,20 @@ struct RemovalFailureAlertTests {#expect(details.filter { $0.contains("Example 30") }.count == 3)}+ @Test func namesTheAppThatSyncsWhatStaysAndItsMarker() {+ let marker = FileManager.default.homeDirectoryForCurrentUser.appending(path: ".stfolder")+ let syncthing = SyncKeeper.app(.syncthing, marker: marker)++ #expect(String(localized: GuardRefusal.inTheCloud(syncthing).explanation) == String(localized: "Peel won’t move this: it is in a folder \("Syncthing") syncs to your other devices (its marker is \("~/.stfolder")), and moving it to the Trash would also remove it from them."))+ #expect(String(localized: GuardRefusal.inTheCloud(.cloud).explanation) == String(localized: "Peel won’t move this: it syncs to your other devices through iCloud or another app, and moving it to the Trash would also remove it from them."))+ #expect(String(localized: HoldBack.inTheCloud.explanation(keptInStepBy: syncthing)) == String(localized: "Left alone: this is in a folder \("Syncthing") syncs to your other devices (its marker is \("~/.stfolder")), and moving it to the Trash would also remove it from them."))+ #expect(+ String(localized: HoldBack.notMeasured.explanation(keptInStepBy: syncthing))+ == String(localized: HoldBack.notMeasured.explanation)+ )+ #expect(ProjectArtifacts.Refusal.inTheCloud(syncthing).explanation == String(localized: "It is in a folder \("Syncthing") syncs to your other devices (its marker is \("~/.stfolder")), which Peel leaves to that app."))+ }+@Test func anUndoThatMacOSRefusedNamesAppManagementAndNotTheMove() {let outcome = RemovalOutcome()outcome.reportPutBack([