Skip to content

armgit / peel

Public Imported from GitHub
0

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

Say that saved settings couldn't be read instead of "not all went back"

Țugui Dragoș95691aeafcb9
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 05b8eec2..eb065e86 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -118406,6 +118406,112 @@
}
}
},
+ "Peel couldn’t read the settings saved for %@, so it put nothing back." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nemohl přečíst nastavení uložená pro aplikaci %@, a proto nic nevrátil zpět."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel konnte die für „%@“ gesicherten Einstellungen nicht lesen, daher wurde nichts zurückgelegt."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel no ha podido leer los ajustes guardados de %@, así que no ha restaurado nada."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel n’a pas pu lire les réglages enregistrés pour %@ : il n’a donc rien remis en place."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel non è riuscito a leggere le impostazioni salvate per %@, quindi non ha ripristinato nulla."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peelは“%@”用に保存された設定を読み取れなかったため、何も戻しませんでした。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel이 ‘%@’에 대해 저장된 설정을 읽을 수 없었으므로 아무것도 되돌려 놓지 않았습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel kon de instellingen die voor %@ zijn bewaard, niet lezen, dus er is niets teruggezet."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nie mógł odczytać ustawień zachowanych dla aplikacji %@, więc niczego nie przywrócił."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O Peel não conseguiu ler os ajustes salvos de %@, então não colocou nada de volta."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nu a putut citi configurările salvate pentru %@, așa că nu a pus nimic înapoi."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не удалось прочитать настройки, сохраненные для приложения «%@», поэтому он ничего не восстановил."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel kunde inte läsa inställningarna som sparades för %@, så inget lades tillbaka."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel, %@ için kaydedilen ayarları okuyamadı, bu yüzden hiçbir şeyi yerine koymadı."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не вдалося прочитати налаштування, збережені для програми «%@», тому нічого не повернуто."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel未能读取为“%@”保存的设置,因此没有放回任何内容。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel無法讀取為「%@」儲存的設定,因此沒有還原任何設定。"
+ }
+ }
+ }
+ },
"Peel couldn’t read your exclusions" : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/PreferenceBackup.swift b/Packages/PeelCore/Sources/PeelCore/Removal/PreferenceBackup.swift
index 12e5f3dd..1e2f4938 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/PreferenceBackup.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/PreferenceBackup.swift
@@ -104,6 +104,8 @@ public enum PreferenceBackup {
case appIsOpen
/// The exclusions aren't read yet or couldn't be read, so nothing was cleared or put back.
case exclusionsNotKnown
+ /// The copy couldn't be read or holds no settings that can be, so nothing was cleared or put back.
+ case copyUnreadable
/// The app is excluded, so its settings were left alone.
case excluded
@@ -162,7 +164,7 @@ public enum PreferenceBackup {
// A copy that is not a readable property list would put nothing back once the delete had cleared the
// settings in use, so it is refused before anything is cleared.
let readable = saved.filter { isAPropertyList($0.1) }
- guard !readable.isEmpty else { return .incomplete(clearedSome: false) }
+ guard !readable.isEmpty else { return .copyUnreadable }
let current = await save(readable.map(\.0), of: bundleIdentifier, in: directory, through: service, run: run)
guard current != .failed else { return .notSaved }
guard await !isOpen() else { return .appIsOpen }
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/RemovalHygieneTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/RemovalHygieneTests.swift
index 54b73a3e..1fb0b325 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/RemovalHygieneTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/RemovalHygieneTests.swift
@@ -415,6 +415,25 @@ struct RemovalHygieneTests {
)
}
+ @Test func aCopyWithNothingToReadPutsNothingBack() async throws {
+ let directory = try TemporaryDirectory()
+ let backups = try directory.directory("Backups")
+ let folder = try directory.directory("Backups/com.example.app 2026-09-24 101500")
+ try Data("not a property list".utf8).write(to: folder.appending(path: "com.example.app.plist"))
+ let asked = Mutex<[[String]]>([])
+ let run: PreferenceBackup.Run = { arguments in
+ asked.withLock { $0.append(arguments) }
+ return Self.exporting(arguments)
+ }
+
+ let restored = await PreferenceBackup.restore(
+ from: folder, of: "com.example.app", in: backups, through: Self.service, run: run, isOpen: { false }
+ )
+
+ #expect(restored == .copyUnreadable, "a copy with nothing to read said only that not all went back")
+ #expect(asked.withLock { $0 }.isEmpty)
+ }
+
/// Put Back replaces what the app set since the reset, which may be a license entered again, so those settings
/// are saved first, as a copy of their own, and only then cleared.
@Test func puttingBackSavesTheSettingsInUseFirst() async throws {
diff --git a/Peel/Views/ResetSheet.swift b/Peel/Views/ResetSheet.swift
index 83639962..755c1824 100644
--- a/Peel/Views/ResetSheet.swift
+++ b/Peel/Views/ResetSheet.swift
@@ -320,7 +320,7 @@ struct ResetSheet: View {
putBack = restored
switch restored {
case .complete, .incomplete: changedFiles = true
- case .notSaved, .appIsOpen, .exclusionsNotKnown, .excluded: break
+ case .notSaved, .appIsOpen, .exclusionsNotKnown, .excluded, .copyUnreadable: break
}
isPuttingBack = false
}
@@ -384,6 +384,10 @@ struct ResetSheet: View {
StatusLabel(title: Text("Peel couldn’t save the settings \(plan.app.name) has now, so it put nothing back."), tint: .red)
.font(.callout)
.foregroundStyle(.secondary)
+ case .copyUnreadable:
+ StatusLabel(title: Text("Peel couldn’t read the settings saved for \(plan.app.name), so it put nothing back."), tint: .red)
+ .font(.callout)
+ .foregroundStyle(.secondary)
case .appIsOpen:
StatusLabel(title: Text("Quit \(plan.app.name) first, or it can write its own settings over these."), tint: .red)
.font(.callout)
diff --git a/Peel/Views/Settings/SavedSettingsSection.swift b/Peel/Views/Settings/SavedSettingsSection.swift
index 742e7662..3777eb8d 100644
--- a/Peel/Views/Settings/SavedSettingsSection.swift
+++ b/Peel/Views/Settings/SavedSettingsSection.swift
@@ -166,6 +166,8 @@ struct SavedSettingsSection: View {
)
case .notSaved:
failure = Failure(title: String(localized: "Peel couldn’t save the settings \(name) has now, so it put nothing back."), message: "")
+ case .copyUnreadable:
+ failure = Failure(title: String(localized: "Peel couldn’t read the settings saved for \(name), so it put nothing back."), message: "")
case .appIsOpen:
failure = Failure(title: String(localized: "Quit \(name) first, or it can write its own settings over these."), message: "")
case .exclusionsNotKnown: