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
Say when Peel can't read its saved copies of settings
Țugui Dragoș0d304cb76092
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 0547c967..28bec540 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -144,6 +144,8 @@ its changes the way [Keep a Changelog](https://keepachangelog.com/) suggests.administrator's password for it.- When many of the folders you choose can't be used, the alert of App Folders and of Exclusions names the first fewand counts the others, so its button stays on the screen, as do the alerts of Build Artifacts and Duplicates.+- When Peel can't read the folder that keeps the saved copies of settings, Saved Settings says so, with Show in Finder,+ rather than not showing at all as if no copy were kept.#### Applicationsdiff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 9bc168af..d5175cec 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -107790,6 +107790,112 @@}}},+ "Peel can’t read the folder that keeps the saved copies of settings, so none can be listed or put back." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel nemůže přečíst složku s uloženými kopiemi nastavení, takže žádnou z nich nelze zobrazit ani vrátit zpět."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel kann den Ordner mit den gesicherten Kopien der Einstellungen nicht lesen, daher kann keine davon angezeigt oder zurückgelegt werden."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel no puede leer la carpeta que contiene las copias guardadas de los ajustes, así que no se puede mostrar ni restaurar ninguna."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel ne peut pas lire le dossier qui conserve les copies enregistrées des réglages : aucune ne peut donc être listée ni remise en place."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel non riesce a leggere la cartella che conserva le copie salvate delle impostazioni, quindi non se ne può elencare né ripristinare nessuna."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peelは、保存された設定のコピーを保管しているフォルダを読み取れないため、コピーを1つも表示できず、戻すこともできません。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel이 저장된 설정 복사본을 보관하는 폴더를 읽을 수 없으므로 어떤 복사본도 나열하거나 되돌려 놓을 수 없습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel kan de map met de bewaarde kopieën van instellingen niet lezen, dus kunnen er geen kopieën worden getoond of teruggezet."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel nie może odczytać folderu z zachowanymi kopiami ustawień, więc żadnej z nich nie można wyświetlić ani przywrócić."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "O Peel não consegue ler a pasta que guarda as cópias salvas dos ajustes, então nenhuma pode ser listada nem colocada de volta."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel nu poate citi dosarul în care sunt păstrate copiile salvate ale configurărilor, așa că niciuna nu poate fi listată sau pusă înapoi."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel не удается прочитать папку с сохраненными копиями настроек, поэтому их нельзя ни показать, ни восстановить."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel kan inte läsa mappen som innehåller de sparade kopiorna av inställningarna, så inga kan listas eller läggas tillbaka."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel, ayarların kaydedilmiş kopyalarını tutan klasörü okuyamıyor, bu yüzden hiçbiri listelenemiyor veya yerine konamıyor."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel не може прочитати папку зі збереженими копіями налаштувань, тож жодної з них не можна показати чи повернути."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel无法读取存放已保存的设置副本的文件夹,因此无法列出任何副本,也无法将其放回原处。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Peel無法讀取存放已儲存的設定副本的檔案夾,因此無法列出或還原任何副本。"+ }+ }+ }+ },"Peel can’t run this file." : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/PreferenceBackup.swift b/Packages/PeelCore/Sources/PeelCore/Removal/PreferenceBackup.swiftindex 6d30da22..12e5f3dd 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/PreferenceBackup.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/PreferenceBackup.swift@@ -191,13 +191,14 @@ public enum PreferenceBackup {public var id: URL { folder }}- /// Lists the saved copies in `directory`, newest first. Only folders named the way `save` names them- /// (bundle identifier, then time, then a number for a second copy in the same second) count; anything else is- /// ignored.- public static func copies(in directory: URL = PreferenceBackup.defaultDirectory) -> [Copy] {- let folders =- (try? FileManager.default.contentsOfDirectory(at: directory, includingPropertiesForKeys: nil)) ?? []- return folders.compactMap { folder -> (copy: Copy, number: Int)? in+ /// Lists the saved copies in `directory`, newest first, or nil when the folder is there and can't be listed. Only+ /// folders named the way `save` names them (bundle identifier, then time, then a number for a second copy in the+ /// same second) count; anything else is ignored.+ public static func copies(in directory: URL = PreferenceBackup.defaultDirectory) -> [Copy]? {+ guard let names = ProtectedData.names(in: directory.path(percentEncoded: false), followingLinks: false) else {+ return nil+ }+ return names.map { directory.appending(path: $0) }.compactMap { folder -> (copy: Copy, number: Int)? in// An identifier has no space, so the name reads as the identifier, the day, the time, and a number.let parts = folder.lastPathComponent.split(separator: " ", omittingEmptySubsequences: false).map(String.init)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/RemovalHygieneTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/RemovalHygieneTests.swiftindex 906de6b6..cdbc4c0f 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/RemovalHygieneTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/RemovalHygieneTests.swift@@ -408,7 +408,7 @@ struct RemovalHygieneTests {)#expect(restored == .complete)- let copies = PreferenceBackup.copies(in: backups)+ let copies = try #require(PreferenceBackup.copies(in: backups))#expect(copies.count == 2, "the settings in use were not kept as a copy of their own")let previous = try #require(copies.first { $0.folder != folder })#expect(FileManager.default.fileExists(atPath: previous.folder.appending(path: "com.example.app.plist").path(percentEncoded: false)))@@ -511,7 +511,7 @@ struct RemovalHygieneTests {#expect(restored == .exclusionsNotKnown)}#expect(asked.withLock { $0 }.isEmpty, "settings were saved, cleared or put back while the exclusions were not known")- #expect(PreferenceBackup.copies(in: backups).count == 1)+ #expect(PreferenceBackup.copies(in: backups)?.count == 1)}@Test func leavesAnExcludedAppsSettingsAlone() async throws {@@ -624,7 +624,7 @@ struct RemovalHygieneTests {return}#expect(one != two)- #expect(PreferenceBackup.copies(in: backups).map(\.folder.lastPathComponent).count == 2)+ #expect(PreferenceBackup.copies(in: backups)?.count == 2)}/// Arc's identifier is `company.thebrowser.Browser` and Obsidian's `md.obsidian`. A copy of their settings is@@ -653,7 +653,7 @@ struct RemovalHygieneTests {continue}}- #expect(Set(PreferenceBackup.copies(in: backups).map(\.bundleIdentifier)) == ["company.thebrowser.Browser", "md.obsidian"])+ #expect(Set(try #require(PreferenceBackup.copies(in: backups)).map(\.bundleIdentifier)) == ["company.thebrowser.Browser", "md.obsidian"])}/// Settings lists the saved copies, newest first, to put back or clear. A copy may hold a license key.@@ -668,7 +668,7 @@ struct RemovalHygieneTests {try directory.directory("Backups/somebody else's folder")try directory.directory("Backups/com.example.app 2026-09-20 093000 x")- let copies = PreferenceBackup.copies(in: backups)+ let copies = try #require(PreferenceBackup.copies(in: backups))#expect(copies.map(\.bundleIdentifier) == ["com.example.app", "com.example.app", "com.other.tool", "com.example.app"])#expect(copies.map(\.folder.lastPathComponent).prefix(2) == ["com.example.app 2026-09-20 093000 2", "com.example.app 2026-09-20 093000"])@@ -679,6 +679,17 @@ struct RemovalHygieneTests {)}+ @Test(.permissionsHold) func aFolderOfCopiesItCannotReadIsNotEmpty() throws {+ let directory = try TemporaryDirectory()+ let backups = try directory.directory("Backups")+ try directory.file("Backups/com.example.app 2026-09-18 101500/com.example.app.plist")+ try directory.setPermissions(0, of: "Backups")+ defer { try? directory.setPermissions(0o755, of: "Backups") }++ #expect(PreferenceBackup.copies(in: backups) == nil)+ #expect(PreferenceBackup.copies(in: directory.url.appending(path: "Missing")) == [])+ }+/// A saved copy can hold a license key or an account, and once the Trash is emptied it may be the only way/// back to those settings, so copies stay until the person clears them in Settings: a new one takes none away.@Test func savedCopiesStayUntilTheyAreCleared() async throws {diff --git a/Peel/Model/SavedSettings.swift b/Peel/Model/SavedSettings.swiftindex c9467cb9..406ba481 100644--- a/Peel/Model/SavedSettings.swift+++ b/Peel/Model/SavedSettings.swift@@ -8,6 +8,7 @@ import PeelCorefinal class SavedSettings {static let shared = SavedSettings()+ /// Nil while the folder that keeps them can't be read.private(set) var copies = PreferenceBackup.copies()private init() {}diff --git a/Peel/Views/Settings/SavedSettingsSection.swift b/Peel/Views/Settings/SavedSettingsSection.swiftindex 323fa7b1..742e7662 100644--- a/Peel/Views/Settings/SavedSettingsSection.swift+++ b/Peel/Views/Settings/SavedSettingsSection.swift@@ -16,14 +16,26 @@ struct SavedSettingsSection: View {/// launch and quit, because a read of the workspace while drawing gives Observation nothing to follow.@State private var openApps: Set<String> = []- private var copies: [PreferenceBackup.Copy] { SavedSettings.shared.copies }+ private var copies: [PreferenceBackup.Copy]? { SavedSettings.shared.copies }var body: some View {Group {- if !copies.isEmpty {+ if copies?.isEmpty != true {Section {- ForEach(copies) { copy in- row(for: copy)+ if let copies {+ ForEach(copies) { copy in+ row(for: copy)+ }+ } else {+ HStack {+ StatusLabel(title: Text("Peel can’t read the folder that keeps the saved copies of settings, so none can be listed or put back."))+ Spacer()+ Button("Show in Finder", systemImage: "folder") {+ NSWorkspace.shared.activateFileViewerSelecting([PreferenceBackup.defaultDirectory])+ }+ .labelStyle(.iconOnly)+ .help(Text("Show in Finder"))+ }}} header: {heading(@@ -123,7 +135,7 @@ struct SavedSettingsSection: View {}private func refreshOpenApps() {- openApps = Set(copies.map(\.bundleIdentifier).filter(isRunning))+ openApps = Set((copies ?? []).map(\.bundleIdentifier).filter(isRunning))}private func putBack(_ copy: PreferenceBackup.Copy, named name: String) async {