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.

Saved settings stay until you clear them

Țugui Dragoșf09debc3945b
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 3333244d..dd618ff1 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -6938,108 +6938,108 @@
}
}
},
- "A reset keeps a copy of the settings it clears, and Put Back works from it even after the app has written new ones. A copy can hold a license key or an account, so clear the ones you no longer need. Peel keeps the newest 20." : {
+ "A reset keeps a copy of the settings it clears, and Put Back works from it even after the app has written new ones. A copy can hold a license key or an account, so clear the ones you no longer need." : {
"localizations" : {
"cs" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Při resetování Peel uloží kopii nastavení, která vymaže, a tlačítko Vrátit zpět z ní nastavení obnoví, i když už aplikace zapsala nová. Kopie může obsahovat licenční klíč nebo účet, proto ty, které už nepotřebujete, odstraňte. Peel uchovává 20 nejnovějších."
+ "value" : "Při resetování Peel uloží kopii nastavení, která vymaže, a tlačítko Vrátit zpět z ní nastavení obnoví, i když už aplikace zapsala nová. Kopie může obsahovat licenční klíč nebo účet, proto ty, které už nepotřebujete, odstraňte."
}
},
"de" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Beim Zurücksetzen wird eine Kopie der entfernten Einstellungen aufbewahrt, und „Zurücklegen“ funktioniert damit auch dann, wenn die App bereits neue geschrieben hat. Eine Kopie kann einen Lizenzschlüssel oder einen Account enthalten, entferne also die, die du nicht mehr brauchst. Peel behält die neuesten 20."
+ "value" : "Beim Zurücksetzen wird eine Kopie der entfernten Einstellungen aufbewahrt, und „Zurücklegen“ funktioniert damit auch dann, wenn die App bereits neue geschrieben hat. Eine Kopie kann einen Lizenzschlüssel oder einen Account enthalten, entferne also die, die du nicht mehr brauchst."
}
},
"es" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Al restablecer una app, se guarda una copia de los ajustes que se borran, y “Restaurar” funciona a partir de ella incluso después de que la app haya escrito ajustes nuevos. Una copia puede contener una clave de licencia o una cuenta, así que elimina las que ya no necesites. Peel conserva las 20 más recientes."
+ "value" : "Al restablecer una app, se guarda una copia de los ajustes que se borran, y “Restaurar” funciona a partir de ella incluso después de que la app haya escrito ajustes nuevos. Una copia puede contener una clave de licencia o una cuenta, así que elimina las que ya no necesites."
}
},
"fr" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Une réinitialisation conserve une copie des réglages qu’elle efface, et « Remettre » s’en sert même après que l’app a écrit de nouveaux réglages. Une copie peut contenir une clé de licence ou un compte : supprimez donc celles dont vous n’avez plus besoin. Peel conserve les 20 plus récentes."
+ "value" : "Une réinitialisation conserve une copie des réglages qu’elle efface, et « Remettre » s’en sert même après que l’app a écrit de nouveaux réglages. Une copie peut contenir une clé de licence ou un compte : supprimez donc celles dont vous n’avez plus besoin."
}
},
"it" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Una reimpostazione conserva una copia delle impostazioni che cancella, e “Ripristina” funziona a partire da quella anche dopo che l’app ne ha scritte di nuove. Una copia può contenere una chiave di licenza o un account, quindi rimuovi quelle che non ti servono più. Peel conserva le 20 più recenti."
+ "value" : "Una reimpostazione conserva una copia delle impostazioni che cancella, e “Ripristina” funziona a partire da quella anche dopo che l’app ne ha scritte di nuove. Una copia può contenere una chiave di licenza o un account, quindi rimuovi quelle che non ti servono più."
}
},
"ja" : {
"stringUnit" : {
"state" : "translated",
- "value" : "リセットでは、消去する設定のコピーが保存され、アプリが新しい設定を書き込んだ後でも、そのコピーから“戻す”を使えます。コピーにはライセンスキーやアカウントが含まれている場合があるため、不要になったものはゴミ箱に入れてください。Peelは最新の20件を保持します。"
+ "value" : "リセットでは、消去する設定のコピーが保存され、アプリが新しい設定を書き込んだ後でも、そのコピーから“戻す”を使えます。コピーにはライセンスキーやアカウントが含まれている場合があるため、不要になったものはゴミ箱に入れてください。"
}
},
"ko" : {
"stringUnit" : {
"state" : "translated",
- "value" : "재설정하면 지워지는 설정의 복사본이 보관되며, ‘되돌려 놓기’는 앱이 새로운 설정을 쓴 후에도 이 복사본으로 작동합니다. 복사본에는 라이센스 키나 계정이 들어 있을 수 있으므로 더 이상 필요 없는 복사본은 지우십시오. Peel은 최신 복사본 20개를 보관합니다."
+ "value" : "재설정하면 지워지는 설정의 복사본이 보관되며, ‘되돌려 놓기’는 앱이 새로운 설정을 쓴 후에도 이 복사본으로 작동합니다. 복사본에는 라이센스 키나 계정이 들어 있을 수 있으므로 더 이상 필요 없는 복사본은 지우십시오."
}
},
"nl" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Bij het opnieuw instellen wordt een kopie bewaard van de instellingen die worden gewist, en 'Zet terug' werkt daarmee, zelfs nadat de app nieuwe instellingen heeft geschreven. Een kopie kan een licentiesleutel of een account bevatten, dus ruim de kopieën op die je niet meer nodig hebt. Peel bewaart de nieuwste 20."
+ "value" : "Bij het opnieuw instellen wordt een kopie bewaard van de instellingen die worden gewist, en 'Zet terug' werkt daarmee, zelfs nadat de app nieuwe instellingen heeft geschreven. Een kopie kan een licentiesleutel of een account bevatten, dus ruim de kopieën op die je niet meer nodig hebt."
}
},
"pl" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Wyzerowanie zachowuje kopię czyszczonych ustawień, a przycisk Przywróć korzysta z niej nawet wtedy, gdy aplikacja zapisała już nowe. Kopia może zawierać klucz licencyjny lub dane konta, więc przenoś do Kosza te, których już nie potrzebujesz. Peel przechowuje 20 najnowszych."
+ "value" : "Wyzerowanie zachowuje kopię czyszczonych ustawień, a przycisk Przywróć korzysta z niej nawet wtedy, gdy aplikacja zapisała już nowe. Kopia może zawierać klucz licencyjny lub dane konta, więc przenoś do Kosza te, których już nie potrzebujesz."
}
},
"pt" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Uma redefinição guarda uma cópia dos ajustes que limpa, e Colocar de Volta usa essa cópia mesmo depois que o app gravou ajustes novos. Uma cópia pode conter uma chave de licença ou uma conta, então remova as de que você não precisa mais. O Peel mantém as 20 mais recentes."
+ "value" : "Uma redefinição guarda uma cópia dos ajustes que limpa, e Colocar de Volta usa essa cópia mesmo depois que o app gravou ajustes novos. Uma cópia pode conter uma chave de licença ou uma conta, então remova as de que você não precisa mais."
}
},
"ro" : {
"stringUnit" : {
"state" : "translated",
- "value" : "O resetare păstrează o copie a configurărilor pe care le elimină, iar butonul Puneți înapoi funcționează pe baza ei chiar și după ce aplicația a scris altele noi. O copie poate conține o cheie de licență sau un cont, așa că eliminați copiile de care nu mai aveți nevoie. Peel le păstrează pe cele mai noi 20."
+ "value" : "O resetare păstrează o copie a configurărilor pe care le elimină, iar butonul Puneți înapoi funcționează pe baza ei chiar și după ce aplicația a scris altele noi. O copie poate conține o cheie de licență sau un cont, așa că eliminați copiile de care nu mai aveți nevoie."
}
},
"ru" : {
"stringUnit" : {
"state" : "translated",
- "value" : "При сбросе сохраняется копия очищаемых настроек, и кнопка «Восстановить» работает с ней, даже если приложение уже записало новые. В копии может быть лицензионный ключ или учетная запись, поэтому удаляйте те копии, которые Вам больше не нужны. Peel хранит 20 последних."
+ "value" : "При сбросе сохраняется копия очищаемых настроек, и кнопка «Восстановить» работает с ней, даже если приложение уже записало новые. В копии может быть лицензионный ключ или учетная запись, поэтому удаляйте те копии, которые Вам больше не нужны."
}
},
"sv" : {
"stringUnit" : {
"state" : "translated",
- "value" : "En nollställning sparar en kopia av inställningarna som den rensar, och Lägg tillbaka fungerar utifrån den även efter att appen har skrivit nya. En kopia kan innehålla en licensnyckel eller ett konto, så rensa bort de kopior som du inte längre behöver. Peel behåller de 20 senaste."
+ "value" : "En nollställning sparar en kopia av inställningarna som den rensar, och Lägg tillbaka fungerar utifrån den även efter att appen har skrivit nya. En kopia kan innehålla en licensnyckel eller ett konto, så rensa bort de kopior som du inte längre behöver."
}
},
"tr" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Bir sıfırlama, temizlediği ayarların bir kopyasını tutar; Yerine Koy, uygulama yeni ayarlar yazdıktan sonra bile bu kopyayı kullanır. Bir kopya lisans anahtarı veya hesap bilgisi içerebilir, bu yüzden artık gerekmeyenleri temizleyin. Peel en yeni 20 kopyayı tutar."
+ "value" : "Bir sıfırlama, temizlediği ayarların bir kopyasını tutar; Yerine Koy, uygulama yeni ayarlar yazdıktan sonra bile bu kopyayı kullanır. Bir kopya lisans anahtarı veya hesap bilgisi içerebilir, bu yüzden artık gerekmeyenleri temizleyin."
}
},
"uk" : {
"stringUnit" : {
"state" : "translated",
- "value" : "Скидання зберігає копію налаштувань, які очищає, і «Повернути назад» працює з цієї копії навіть після того, як програма записала нові. Копія може містити ліцензійний ключ чи дані облікового запису, тож вилучайте ті копії, які вам більше не потрібні. Peel зберігає 20 найновіших."
+ "value" : "Скидання зберігає копію налаштувань, які очищає, і «Повернути назад» працює з цієї копії навіть після того, як програма записала нові. Копія може містити ліцензійний ключ чи дані облікового запису, тож вилучайте ті копії, які вам більше не потрібні."
}
},
"zh-Hans" : {
"stringUnit" : {
"state" : "translated",
- "value" : "重置时会保留一份所清除设置的副本,即使App之后写入了新设置,“放回原处”也能根据副本恢复。副本中可能包含许可证密钥或账户,因此请清除不再需要的副本。Peel会保留最新的20份。"
+ "value" : "重置时会保留一份所清除设置的副本,即使App之后写入了新设置,“放回原处”也能根据副本恢复。副本中可能包含许可证密钥或账户,因此请清除不再需要的副本。"
}
},
"zh-Hant" : {
"stringUnit" : {
"state" : "translated",
- "value" : "重置時會保留一份它所清除之設定的副本,即使App已寫入新的設定,「還原」仍可依據此副本運作。副本中可能含有授權碼或帳號,因此請清除你不再需要的副本。Peel會保留最新的20份。"
+ "value" : "重置時會保留一份它所清除之設定的副本,即使App已寫入新的設定,「還原」仍可依據此副本運作。副本中可能含有授權碼或帳號,因此請清除你不再需要的副本。"
}
}
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/PreferenceBackup.swift b/Packages/PeelCore/Sources/PeelCore/Removal/PreferenceBackup.swift
index 719f4e77..d5dd82f3 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/PreferenceBackup.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/PreferenceBackup.swift
@@ -4,9 +4,6 @@ internal import PeelPrivileged
/// Saves an app's preference domains with `defaults export` before a reset clears them. History can put the
/// plists back only until the app writes new ones; a saved copy still works after that.
public enum PreferenceBackup {
- /// How many saved copies are kept. Older ones go to the Trash.
- static let maximumBackups = 20
-
public static var defaultDirectory: URL {
PeelFolder.url.appending(path: "Preference Backups", directoryHint: .isDirectory)
}
@@ -74,7 +71,6 @@ public enum PreferenceBackup {
return .failed
}
}
- await prune(directory, through: service)
return .saved(folder)
}
@@ -177,24 +173,4 @@ public enum PreferenceBackup {
}
return output.status == 0 ? .yes : .no
}
-
- /// Moves the folders beyond the newest `maximumBackups` to the Trash, never deleting them: once the Trash
- /// has been emptied, a saved copy may be the only way back to those settings.
- static func prune(_ directory: URL, through service: TrashService) async {
- let keys: Set<URLResourceKey> = [.isDirectoryKey, .creationDateKey]
- guard let contents = try? FileManager.default.contentsOfDirectory(
- at: directory,
- includingPropertiesForKeys: Array(keys),
- options: [.skipsHiddenFiles]
- ) else { return }
-
- let folders = contents
- .filter { (try? $0.resourceValues(forKeys: keys).isDirectory) == true }
- .sorted { left, right in
- let leftDate = (try? left.resourceValues(forKeys: keys).creationDate) ?? .distantPast
- let rightDate = (try? right.resourceValues(forKeys: keys).creationDate) ?? .distantPast
- return leftDate > rightDate
- }
- _ = await service.trash(Array(folders.dropFirst(maximumBackups)))
- }
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/RemovalHygieneTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/RemovalHygieneTests.swift
index 86aa678d..f0350052 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/RemovalHygieneTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/RemovalHygieneTests.swift
@@ -290,15 +290,13 @@ struct RemovalHygieneTests {
#expect(copies.first?.date == DateComponents(calendar: .current, year: 2026, month: 9, day: 20, hour: 9, minute: 30, second: 0).date)
}
- /// Once the Trash has been emptied, a saved copy is the only way back to those settings, so copies past the
- /// newest twenty go to the Trash and are never deleted.
- @Test func oldBackupsGoToTheTrashAndAreNeverDeleted() async throws {
+ /// 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 {
let directory = try TemporaryDirectory()
let backups = try directory.directory("home/Library/Application Support/Peel/Preference Backups")
- for index in 0..<(PreferenceBackup.maximumBackups + 2) {
- let folder = try directory.directory("home/Library/Application Support/Peel/Preference Backups/com.example.app \(index)")
- let made = Date(timeIntervalSince1970: TimeInterval(1_700_000_000 + index * 60))
- try FileManager.default.setAttributes([.creationDate: made], ofItemAtPath: folder.path(percentEncoded: false))
+ for index in 0..<22 {
+ try directory.directory("home/Library/Application Support/Peel/Preference Backups/com.example.app \(index)")
}
let moved = Mutex<[String]>([])
let service = TrashService(
@@ -308,34 +306,6 @@ struct RemovalHygieneTests {
return url
}
)
-
- await PreferenceBackup.prune(backups, through: service)
-
- #expect(moved.withLock { $0 }.sorted() == ["com.example.app 0", "com.example.app 1"], "the two oldest, and only through the Trash")
- #expect(try FileManager.default.contentsOfDirectory(atPath: backups.path(percentEncoded: false)).count == PreferenceBackup.maximumBackups + 2, "something was unlinked")
- }
-
- /// Peel never moves anything the user excluded, and pruning old copies is no exception: an excluded copy
- /// stays even when it is older than the newest twenty.
- @Test func anExcludedCopyIsNeverTakenToKeepTheNewestTwenty() async throws {
- let directory = try TemporaryDirectory()
- let backups = try directory.directory("home/Library/Application Support/Peel/Preference Backups")
- var oldest: URL?
- for index in 0..<(PreferenceBackup.maximumBackups + 2) {
- let folder = try directory.directory("home/Library/Application Support/Peel/Preference Backups/com.example.app \(index)")
- let made = Date(timeIntervalSince1970: TimeInterval(1_700_000_000 + index * 60))
- try FileManager.default.setAttributes([.creationDate: made], ofItemAtPath: folder.path(percentEncoded: false))
- if index == 0 { oldest = folder }
- }
- let moved = Mutex<[String]>([])
- let service = TrashService(
- environment: SearchEnvironment(homeDirectory: directory.url.appending(path: "home"), rootDirectory: directory.url.appending(path: "root")),
- exclusions: Exclusions(paths: [try #require(oldest)]),
- moveToTrash: { url in
- moved.withLock { $0.append(url.lastPathComponent) }
- return url
- }
- )
let app = InstalledApp(url: URL(filePath: "/Applications/Example.app"), bundleIdentifier: "com.example.app", name: "Example")
let plist = URL.homeDirectory.appending(path: "Library/Preferences/com.example.app.plist")
@@ -347,7 +317,8 @@ struct RemovalHygieneTests {
}
guard case .saved = saved else { Issue.record("the copy was not made: \(saved)"); return }
- #expect(moved.withLock { $0 }.sorted() == ["com.example.app 1", "com.example.app 2"], "the excluded copy was taken")
+ #expect(moved.withLock { $0 }.isEmpty, "a saved copy was taken away")
+ #expect(try FileManager.default.contentsOfDirectory(atPath: backups.path(percentEncoded: false)).count == 23)
}
@Test func leavesSensitiveFilesOutOfOrphans() {
diff --git a/Peel/Views/Settings/SavedSettingsSection.swift b/Peel/Views/Settings/SavedSettingsSection.swift
index cf7bdaa7..5da96581 100644
--- a/Peel/Views/Settings/SavedSettingsSection.swift
+++ b/Peel/Views/Settings/SavedSettingsSection.swift
@@ -25,7 +25,7 @@ struct SavedSettingsSection: View {
} header: {
heading(
"Saved Settings",
- "A reset keeps a copy of the settings it clears, and Put Back works from it even after the app has written new ones. A copy can hold a license key or an account, so clear the ones you no longer need. Peel keeps the newest 20."
+ "A reset keeps a copy of the settings it clears, and Put Back works from it even after the app has written new ones. A copy can hold a license key or an account, so clear the ones you no longer need."
)
}
}
diff --git a/SAFETY.md b/SAFETY.md
index 94bb2f69..203d5253 100644
--- a/SAFETY.md
+++ b/SAFETY.md
@@ -230,15 +230,15 @@ start over in Settings, `peel` refuses, and the file it could not read is kept b
## Resetting an app
-A reset clears an app's settings and never the app itself. It lists only files that are certainly that app's, and
-the app has to be quit, both when the reset starts and when saved settings are put back. Before anything moves,
-Peel saves the app's settings, and if that copy fails, nothing moves; Settings lists the saved copies, where each
-can be put back or cleared, since one can hold a license key. What the app keeps for you (its Application Support
-folder, group containers, and application scripts) goes only when you select it, and is never offered for Mail,
-Messages, Notes, or Photos. Inside a sandboxed app's container, a reset touches only the app's preferences, saved
-state, caches, logs, and web data, never `Documents`, `Application Support`, or `Autosave Information`; web data,
-which signs you out of websites, is offered but never selected for you. A folder that holds a wallet's keys is never
-offered, even among those: BlueWallet keeps its wallet in its container's caches.
+A reset clears an app's settings and never the app itself. It lists only files that are certainly that app's, and the
+app has to be quit, both when the reset starts and when saved settings are put back. Before anything moves, Peel saves
+the app's settings, and if that copy fails, nothing moves; Settings lists the saved copies, where each can be put back
+or cleared, since one can hold a license key, and they stay until you clear them. What the app keeps for you (its
+Application Support folder, group containers, and application scripts) goes only when you select it, and is never
+offered for Mail, Messages, Notes, or Photos. Inside a sandboxed app's container, a reset touches only the app's
+preferences, saved state, caches, logs, and web data, never `Documents`, `Application Support`, or
+`Autosave Information`; web data, which signs you out of websites, is offered but never selected for you. A folder that
+holds a wallet's keys is never offered, even among those: BlueWallet keeps its wallet in its container's caches.
## The helper that runs as root