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.

Call what stands in an edited file's place a version, both ways

Țugui Dragoșaa476beb7cee
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 3135f7f0..7adcf688 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -20084,6 +20084,112 @@
}
}
},
+ "Another version of it is in its place now, so Put Back moves that one to the Trash first, where History keeps it." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Na jeho místě je teď jiná verze, takže ji tlačítko Vrátit zpět nejdřív přesune do koše, kde ji Historie uchová."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "An seiner Stelle liegt jetzt eine andere Version davon, daher legt „Zurücklegen“ diese zuerst in den Papierkorb, und der Verlauf behält sie."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ahora ocupa su lugar otra versión, así que “Restaurar” traslada primero esa versión a la papelera, donde Historial la conserva."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Une autre version de cet élément se trouve maintenant à sa place : « Remettre » commence donc par placer cette version dans la corbeille, où l’Historique la conserve."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Al suo posto ora c’è un’altra versione dell’elemento, quindi “Ripristina” sposta prima quella nel Cestino, dove la Cronologia la conserva."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "現在その場所には別のバージョンがあるため、“戻す”は先にそのバージョンをゴミ箱に入れます。そのバージョンも履歴に残ります。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "현재 그 자리에 이 항목의 다른 버전이 있으므로, ‘되돌려 놓기’는 먼저 그 버전을 휴지통으로 이동하며, 이동한 버전은 기록에 보관됩니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Op de plek ervan staat nu een andere versie, dus 'Zet terug' verplaatst die eerst naar de prullenmand, waar Geschiedenis die bewaart."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Na miejscu tej rzeczy jest teraz inna jej wersja, więc przycisk Przywróć najpierw przeniesie tę wersję do Kosza, gdzie Historia ją zachowa."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Outra versão do item está agora no lugar dele, então o comando Colocar de Volta primeiro move essa versão para o Lixo, onde o Histórico a mantém."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "În locul său se află acum o altă versiune a acestuia, așa că butonul Puneți înapoi o mută mai întâi pe aceasta în Coș, unde Istoricul o păstrează."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Сейчас на его месте находится другая его версия, поэтому кнопка «Восстановить» сначала переместит ее в Корзину, где ее сохранит История."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "En annan version av det ligger nu på dess plats, så ”Lägg tillbaka” flyttar först den versionen till papperskorgen, där Historik behåller den."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Şu anda yerinde başka bir sürümü duruyor, bu yüzden Yerine Koy, önce o sürümü Çöp Sepeti’ne taşır; Geçmiş onu da orada tutar."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Зараз на його місці інша версія, тому «Повернути назад» спершу переміщує цю версію в Смітник, де її зберігає Історія."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "现在位于原位置的是它的另一个版本,因此“放回原处”会先将那个版本移到废纸篓,“历史记录”会保留它。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "它的原處現在是另一個版本,因此「還原」會先將該版本丟到「垃圾桶」,並由「歷史記錄」保留。"
+ }
+ }
+ }
+ },
"Any kind" : {
"localizations" : {
"cs" : {
@@ -200511,112 +200617,6 @@
}
}
},
- "The edit in its place couldn’t move to the Trash first, so nothing changed." : {
- "localizations" : {
- "cs" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Úpravu, která je teď na jeho místě, se nejdřív nepodařilo přesunout do koše, takže se nic nezměnilo."
- }
- },
- "de" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Die bearbeitete Fassung, die an seiner Stelle liegt, konnte nicht zuerst in den Papierkorb gelegt werden, daher wurde nichts geändert."
- }
- },
- "es" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "No se ha podido trasladar primero a la papelera la versión editada que ocupa su lugar, así que no ha cambiado nada."
- }
- },
- "fr" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Impossible de placer d’abord dans la corbeille la version modifiée qui se trouve à sa place : rien n’a donc changé."
- }
- },
- "it" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Non è stato possibile spostare prima nel Cestino la versione modificata che si trova al suo posto, quindi non è cambiato nulla."
- }
- },
- "ja" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "その場所にある編集版を先にゴミ箱に入れられなかったため、何も変更されていません。"
- }
- },
- "ko" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "현재 그 자리에 있는 편집본을 먼저 휴지통으로 이동할 수 없어 아무것도 변경되지 않았습니다."
- }
- },
- "nl" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "De versie die nu op de plek ervan staat, kon niet eerst naar de prullenmand worden verplaatst, dus er is niets gewijzigd."
- }
- },
- "pl" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Nie udało się najpierw przenieść do Kosza wersji, która jest teraz na miejscu tej rzeczy, więc nic się nie zmieniło."
- }
- },
- "pt" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Não foi possível mover primeiro para o Lixo a edição que agora está no lugar do item, então nada mudou."
- }
- },
- "ro" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Versiunea editată aflată în locul său nu a putut fi mutată mai întâi în Coș, așa că nu s‑a schimbat nimic."
- }
- },
- "ru" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Отредактированную версию, которая сейчас находится на его месте, не удалось сначала переместить в Корзину, поэтому ничего не изменилось."
- }
- },
- "sv" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Versionen som nu ligger på dess plats kunde inte flyttas till papperskorgen först, så ingenting ändrades."
- }
- },
- "tr" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Yerinde duran düzenlenmiş hâli önce Çöp Sepeti’ne taşınamadı, bu yüzden hiçbir şey değişmedi."
- }
- },
- "uk" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Не вдалося спершу перемістити в Смітник відредагований варіант, який на його місці, тому нічого не змінено."
- }
- },
- "zh-Hans" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "未能先将位于原位置的编辑后的版本移到废纸篓,因此没有任何更改。"
- }
- },
- "zh-Hant" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "目前位於原處的編輯版本無法先丟到「垃圾桶」,因此沒有任何變更。"
- }
- }
- }
- },
"The extra section at the end goes away." : {
"localizations" : {
"cs" : {
@@ -205920,6 +205920,112 @@
}
}
},
+ "The version now in its place couldn’t move to the Trash first, so nothing changed." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Verzi, která je teď na jeho místě, se nejdřív nepodařilo přesunout do koše, takže se nic nezměnilo."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Die Version, die jetzt an seiner Stelle liegt, konnte nicht zuerst in den Papierkorb gelegt werden, daher wurde nichts geändert."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "No se ha podido trasladar primero a la papelera la versión que ahora ocupa su lugar, así que no ha cambiado nada."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Impossible de placer d’abord dans la corbeille la version qui se trouve maintenant à sa place : rien n’a donc changé."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Non è stato possibile spostare prima nel Cestino la versione che ora si trova al suo posto, quindi non è cambiato nulla."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "現在その場所にあるバージョンを先にゴミ箱に入れられなかったため、何も変更されていません。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "현재 그 자리에 있는 버전을 먼저 휴지통으로 이동할 수 없어 아무것도 변경되지 않았습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "De versie die nu op de plek ervan staat, kon niet eerst naar de prullenmand worden verplaatst, dus er is niets gewijzigd."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nie udało się najpierw przenieść do Kosza wersji, która jest teraz na miejscu tej rzeczy, więc nic się nie zmieniło."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Não foi possível mover primeiro para o Lixo a versão que agora está no lugar do item, então nada mudou."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Versiunea aflată acum în locul său nu a putut fi mutată mai întâi în Coș, așa că nu s‑a schimbat nimic."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Версию, которая сейчас находится на его месте, не удалось сначала переместить в Корзину, поэтому ничего не изменилось."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Versionen som nu ligger på dess plats kunde inte flyttas till papperskorgen först, så ingenting ändrades."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Şu anda yerinde duran sürüm önce Çöp Sepeti’ne taşınamadı, bu yüzden hiçbir şey değişmedi."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Не вдалося спершу перемістити в Смітник версію, яка зараз на його місці, тому нічого не змінено."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未能先将现在位于原位置的版本移到废纸篓,因此没有任何更改。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "目前位於原處的版本無法先丟到「垃圾桶」,因此沒有任何變更。"
+ }
+ }
+ }
+ },
"The versions of Rust that rustup installed, each a whole compiler and standard library." : {
"localizations" : {
"cs" : {
@@ -234449,112 +234555,6 @@
}
}
},
- "Your edit of it stands in its place, so Put Back moves that edit to the Trash first, where History keeps it." : {
- "localizations" : {
- "cs" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Na jeho místě je teď vaše úprava, takže ji tlačítko Vrátit zpět nejdřív přesune do koše, kde ji Historie uchová."
- }
- },
- "de" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "An seiner Stelle liegt deine bearbeitete Fassung, daher legt „Zurücklegen“ diese zuerst in den Papierkorb, und der Verlauf behält sie."
- }
- },
- "es" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Tu versión editada ocupa su lugar, así que “Restaurar” traslada primero esa versión editada a la papelera, donde Historial la conserva."
- }
- },
- "fr" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Votre version modifiée de cet élément se trouve à sa place : « Remettre » commence donc par placer cette version modifiée dans la corbeille, où l’Historique la conserve."
- }
- },
- "it" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Al suo posto c’è la tua versione modificata dell’elemento, quindi “Ripristina” sposta prima quella nel Cestino, dove la Cronologia la conserva."
- }
- },
- "ja" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "その場所には編集版があるため、“戻す”は先にその編集版をゴミ箱に入れます。その編集版も履歴に残ります。"
- }
- },
- "ko" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "현재 그 자리에 이 항목의 편집본이 있으므로, ‘되돌려 놓기’는 먼저 그 편집본을 휴지통으로 이동하며, 이동한 편집본은 기록에 보관됩니다."
- }
- },
- "nl" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Op de plek ervan staat nu een andere versie, dus 'Zet terug' verplaatst die eerst naar de prullenmand, waar Geschiedenis die bewaart."
- }
- },
- "pl" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Na miejscu tej rzeczy jest teraz inna jej wersja, więc przycisk Przywróć najpierw przeniesie tę wersję do Kosza, gdzie Historia ją zachowa."
- }
- },
- "pt" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "A sua edição do item está agora no lugar dele, então o comando Colocar de Volta primeiro move essa edição para o Lixo, onde o Histórico a mantém."
- }
- },
- "ro" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "În locul său se află acum versiunea editată de dvs., așa că butonul Puneți înapoi o mută mai întâi pe aceasta în Coș, unde Istoricul o păstrează."
- }
- },
- "ru" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Сейчас на его месте находится отредактированная Вами версия, поэтому кнопка «Восстановить» сначала переместит ее в Корзину, где ее сохранит История."
- }
- },
- "sv" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "En annan version av det ligger nu på dess plats, så ”Lägg tillbaka” flyttar först den versionen till papperskorgen, där Historik behåller den."
- }
- },
- "tr" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "Yerinde, sizin düzenlediğiniz hâli duruyor, bu yüzden Yerine Koy, önce o düzenlenmiş hâli Çöp Sepeti’ne taşır; Geçmiş onu da orada tutar."
- }
- },
- "uk" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "На його місці стоїть ваш відредагований варіант, тому «Повернути назад» спершу переміщує цей варіант у Смітник, де його зберігає Історія."
- }
- },
- "zh-Hans" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "位于原位置的是你编辑后的版本,因此“放回原处”会先将那个编辑后的版本移到废纸篓,“历史记录”会保留它。"
- }
- },
- "zh-Hant" : {
- "stringUnit" : {
- "state" : "translated",
- "value" : "它的原處現在是你的編輯版本,因此「還原」會先將該編輯版本丟到「垃圾桶」,並由「歷史記錄」保留。"
- }
- }
- }
- },
"Your exclusions couldn’t be saved" : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swift
index ef1e01a5..f02af266 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/HistoryCommands.swift
@@ -401,8 +401,8 @@ struct RestoreCommand: AsyncParsableCommand {
for (record, failure) in refused {
Output.note("\(Output.plain(Output.path(record.originalURL))) stays: \(failure.summary)")
}
- for record in going where record.trashedItem.editStandsInItsPlace {
- Output.note("\(Output.plain(Output.path(record.originalURL))): the edit in its place goes to the Trash first, and History keeps it.")
+ for record in going where record.trashedItem.replacementStandsInItsPlace {
+ Output.note("\(Output.plain(Output.path(record.originalURL))): the version now in its place goes to the Trash first, and History keeps it.")
}
guard !going.isEmpty else {
@@ -435,13 +435,13 @@ struct RestoreCommand: AsyncParsableCommand {
restored.insert(record.id)
}
}
- // An edit that made room goes into History under the same part, so it can come back too.
+ // What made room goes into History under the same part, so it can come back too.
var aside: [RemovalRecord] = []
- for (record, edit) in zip(ordered, answers.movedAside) {
- guard let edit else { continue }
- let size = await FileSize.reclaimableSize(of: edit.trashedURL)
- let sizes = size.map { [edit.originalURL: $0] } ?? [:]
- aside += record.part.records(of: TrashResult(trashed: [edit]), sizes: sizes, batch: UUID())
+ for (record, movedAside) in zip(ordered, answers.movedAside) {
+ guard let movedAside else { continue }
+ let size = await FileSize.reclaimableSize(of: movedAside.trashedURL)
+ let sizes = size.map { [movedAside.originalURL: $0] } ?? [:]
+ aside += record.part.records(of: TrashResult(trashed: [movedAside]), sizes: sizes, batch: UUID())
}
let kept = aside.isEmpty ? true : await log.add(aside).records != nil
return (restored, failures, await log.remove(restored).records != nil && kept)
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
index e5536704..e56cfccf 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
@@ -277,7 +277,8 @@ extension RestoreFailure {
"macOS lets your terminal app put back another developer's app only with App Management; allow it in System Settings > Privacy & Security > App Management, or put it back with the Peel app"
case .notPermitted: "macOS didn't allow it"
case .failed(let message): Output.plain(message)
- case .editStays(let reason): "the edit in its place couldn't move to the Trash first (\(reason.summary))"
+ case .replacementStays(let reason):
+ "the version now in its place couldn't move to the Trash first (\(reason.summary))"
}
}
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalHistory.swift b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalHistory.swift
index d779c5aa..e3929903 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/RemovalHistory.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/RemovalHistory.swift
@@ -22,7 +22,7 @@ public struct RemovalRecord: Sendable, Codable, Hashable, Identifiable {
/// History can show it in the user's language. `source` then holds the English name, which `peel` prints.
public let sourceKey: String?
public let stoppedJob: String?
- /// The file an edit wrote in the item's place, which a Put Back moves to the Trash first.
+ /// The version that took the item's place, which a Put Back moves to the Trash first.
public let replacedBy: TrashedItem.Identity?
/// True when the item shared most of its storage with another copy, so moving it freed only its own part.
public let sharedStorage: Bool?
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift
index 00d0071b..8139be78 100644
--- a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift
@@ -11,7 +11,8 @@ public struct TrashedItem: Sendable, Hashable, Codable {
public let identity: Identity?
/// The launchd job Peel stopped once this file moved, by its label, which putting the file back starts again.
public internal(set) var stoppedJob: String?
- /// The file an edit of this one wrote in its place, which a Put Back moves to the Trash before this goes back.
+ /// The version that took this one's place, an edit of it or the version an edit replaced, which a Put Back moves
+ /// to the Trash before this goes back.
public internal(set) var replacedBy: Identity?
/// An item as its volume knows it: its inode and when it was made, which a move within the volume keeps. The
@@ -44,8 +45,8 @@ public struct TrashedItem: Sendable, Hashable, Codable {
self.replacedBy = replacedBy
}
- /// True while the file an edit of this one wrote stands in its place, never a link taken for it.
- public var editStandsInItsPlace: Bool {
+ /// True while the version that took this one's place stands there, never a link taken for it.
+ public var replacementStandsInItsPlace: Bool {
guard let replacedBy else { return false }
return Identity(ofItemAt: originalURL) == replacedBy
}
@@ -254,15 +255,15 @@ public enum RestoreFailure: Sendable, Hashable {
/// macOS's privacy protection refused it.
case notPermitted
case failed(String)
- /// The file an edit of it wrote in its place couldn't move to the Trash first, for this reason.
- case editStays(TrashFailure.Reason)
+ /// The version in its place couldn't move to the Trash first, for this reason.
+ case replacementStays(TrashFailure.Reason)
/// True when asking again can't help: the item left the Trash, or Peel puts nothing back from or to there.
public var isFinal: Bool {
switch self {
case .missingFromTrash, .notAllowed, .notAllowedByTheHelper, .notInATrash: true
case .alreadyThere, .needsHelper, .locked, .folderLocked, .folderGone, .needsAppManagement, .notPermitted,
- .failed, .editStays:
+ .failed, .replacementStays:
false
}
}
@@ -841,26 +842,26 @@ public struct TrashService: Sendable {
await putBack(item, canUseHelper: canUseHelper).failure
}
- /// Puts `item` back, first moving to the Trash the file an edit of it wrote in its place, which comes back as the
- /// item moved aside. Should `item` not go back after all, the edit goes back to its place.
+ /// Puts `item` back, first moving to the Trash the version in its place, which comes back as the item moved
+ /// aside. Should `item` not go back after all, that version goes back to its place.
private func putBack(
_ item: TrashedItem, canUseHelper: Bool
) async -> (failure: RestoreFailure?, movedAside: TrashedItem?) {
var movedAside: TrashedItem?
- if item.editStandsInItsPlace {
+ if item.replacementStandsInItsPlace {
if let refusal = refusal(ofPuttingBack: item, canUseHelper: canUseHelper) { return (refusal, nil) }
let moved = await trash([item.originalURL])
- guard var edit = moved.trashed.first else {
- return (.editStays(moved.failures.first?.reason ?? .changedSinceScan), nil)
+ guard var replacement = moved.trashed.first else {
+ return (.replacementStays(moved.failures.first?.reason ?? .changedSinceScan), nil)
}
- edit.replacedBy = item.identity
- movedAside = edit
+ replacement.replacedBy = item.identity
+ movedAside = replacement
}
let failure = await moveBack(item, canUseHelper: canUseHelper)
guard failure == nil else {
guard let movedAside else { return (failure, nil) }
- let editBack = await putBack(movedAside, canUseHelper: canUseHelper)
- return (failure, editBack.failure == nil ? nil : movedAside)
+ let replacementBack = await putBack(movedAside, canUseHelper: canUseHelper)
+ return (failure, replacementBack.failure == nil ? nil : movedAside)
}
journal?.forget([item])
// The label comes from History, which any process of the user can rewrite, so the job starts only as the
@@ -884,9 +885,9 @@ public struct TrashService: Sendable {
}
guard item.isInTheTrash else { return .missingFromTrash }
if item.originalURL.isThere {
- guard item.editStandsInItsPlace else { return .alreadyThere }
- if FileAccess.isLockedInFinder(item.originalURL) { return .editStays(.locked) }
- if let refusal = refusal(of: item.originalURL) { return .editStays(refusal) }
+ guard item.replacementStandsInItsPlace else { return .alreadyThere }
+ if FileAccess.isLockedInFinder(item.originalURL) { return .replacementStays(.locked) }
+ if let refusal = refusal(of: item.originalURL) { return .replacementStays(refusal) }
}
if FileAccess.isLockedInFinder(item.trashedURL) { return .locked }
let folder = URL(filePath: Self.folder(puttingBack: item))
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/EditPutBackTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/EditPutBackTests.swift
index 12a8e9ec..be0ebb2f 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/EditPutBackTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/EditPutBackTests.swift
@@ -93,7 +93,7 @@ struct EditPutBackTests {
var another = moved
another.replacedBy = TrashedItem.Identity(ofItemAt: agent.trash)
- #expect(moved.editStandsInItsPlace)
+ #expect(moved.replacementStandsInItsPlace)
#expect(service.refusal(ofPuttingBack: moved, canUseHelper: false) == nil)
#expect(service.refusal(ofPuttingBack: unrecorded, canUseHelper: false) == .alreadyThere)
#expect(service.refusal(ofPuttingBack: another, canUseHelper: false) == .alreadyThere)
@@ -113,6 +113,7 @@ struct EditPutBackTests {
#expect(try agent.text(at: agent.place) == "old")
#expect(try agent.text(at: aside.trashedURL) == "edited")
#expect(aside.replacedBy == moved.identity)
+ #expect(aside.replacementStandsInItsPlace)
#expect(agent.started.all.isEmpty, "the file holds no job launchd could read, so none starts")
let again = await service.restore([aside])
@@ -147,11 +148,11 @@ struct EditPutBackTests {
let result = await service.restore([moved])
- #expect(result.failures == [.editStays(.locked)])
+ #expect(result.failures == [.replacementStays(.locked)])
#expect(result.movedAside == [nil])
#expect(try agent.text(at: agent.place) == "edited")
#expect(try agent.text(at: moved.trashedURL) == "old")
- #expect(service.refusal(ofPuttingBack: moved, canUseHelper: false) == .editStays(.locked))
+ #expect(service.refusal(ofPuttingBack: moved, canUseHelper: false) == .replacementStays(.locked))
}
@Test func putsTheEditBackWhenTheOldFileCannotGoBack() async throws {
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swift
index 58d49197..466e8a33 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/HistoryCommandTests.swift
@@ -646,7 +646,7 @@ struct HistoryCommandTests {
#expect(real.failure != nil)
}
- @Test func aRestoreMovesTheEditInItsPlaceToTheTrashFirstAndKeepsItInHistory() async throws {
+ @Test func aRestoreMovesTheVersionInItsPlaceToTheTrashFirstAndKeepsItInHistory() async throws {
let directory = try TemporaryDirectory()
let logs = logs(in: directory)
let place = try directory.file("home/Library/LaunchAgents/org.example.edit.plist", contents: Data("edited".utf8))
@@ -668,26 +668,29 @@ struct HistoryCommandTests {
try FileManager.default.moveItem(at: url, to: destination)
return destination
}
- func run(_ flag: String) async throws -> String {
+ func run(_ batch: UUID, _ flag: String) async throws -> String {
let collected = Output.Collected()
- let command: RestoreCommand = try command(["restore", String(record.batch.uuidString.prefix(8)), flag])
+ let command: RestoreCommand = try command(["restore", String(batch.uuidString.prefix(8)), flag])
try await Output.$collected.withValue(collected) {
try await command.run(in: logs.removals, using: service)
}
return collected.output + collected.notes
}
- let dry = try await run("--dry-run")
- #expect(dry.contains("the edit in its place goes to the Trash first, and History keeps it"), "\(dry)")
+ let sentence = "the version now in its place goes to the Trash first, and History keeps it"
+ let dry = try await run(record.batch, "--dry-run")
+ #expect(dry.contains(sentence), "\(dry)")
#expect(try String(contentsOf: place, encoding: .utf8) == "edited")
- let real = try await run("-y")
+ let real = try await run(record.batch, "-y")
#expect(real.contains("Put 1 item back."), "\(real)")
#expect(try String(contentsOf: place, encoding: .utf8) == "old")
let kept = await logs.removals.load().records ?? []
#expect(kept.map(\.originalURL) == [place])
#expect(kept.first?.replacedBy == TrashedItem.Identity(ofItemAt: place))
#expect(try kept.first.map { try String(contentsOf: $0.trashedURL, encoding: .utf8) } == "edited")
+ let back = try await run(try #require(kept.first).batch, "--dry-run")
+ #expect(back.contains(sentence), "\(back)")
}
@Test func saysSoWhenEverythingLeftIsRefused() async throws {
diff --git a/Peel/Model/RemovalHistoryStore.swift b/Peel/Model/RemovalHistoryStore.swift
index 8db2a71e..8ab03bf9 100644
--- a/Peel/Model/RemovalHistoryStore.swift
+++ b/Peel/Model/RemovalHistoryStore.swift
@@ -537,13 +537,13 @@ final class RemovalHistoryStore {
restored.insert(record.id)
}
}
- // An edit that made room goes into History under the same part, so it can come back too.
+ // What made room goes into History under the same part, so it can come back too.
var aside = RemovalInProgress()
- for (record, edit) in zip(ordered, answers.movedAside) {
- guard let edit else { continue }
- let size = await FileSize.reclaimableSize(of: edit.trashedURL)
- let sizes = size.map { [edit.originalURL: $0] } ?? [:]
- await self.record(TrashResult(trashed: [edit]), part: record.part, sizes: sizes, in: &aside)
+ for (record, movedAside) in zip(ordered, answers.movedAside) {
+ guard let movedAside else { continue }
+ let size = await FileSize.reclaimableSize(of: movedAside.trashedURL)
+ let sizes = size.map { [movedAside.originalURL: $0] } ?? [:]
+ await self.record(TrashResult(trashed: [movedAside]), part: record.part, sizes: sizes, in: &aside)
}
for record in ordered {
failures[record.id] = problems[record.id]
diff --git a/Peel/Views/History/HistoryDetailView.swift b/Peel/Views/History/HistoryDetailView.swift
index c5e454ca..fe4eac87 100644
--- a/Peel/Views/History/HistoryDetailView.swift
+++ b/Peel/Views/History/HistoryDetailView.swift
@@ -226,14 +226,14 @@ private enum RecordPlace {
private enum RecordNote {
case sharedStorage
case loadsAfterARestart
- case editStandsInItsPlace
+ case replacementStandsInItsPlace
var text: LocalizedStringResource {
switch self {
case .sharedStorage: "It shared most of its storage with another copy, so moving it freed only its own part."
case .loadsAfterARestart: "Once put back, macOS loads this audio driver only after you restart your Mac."
- case .editStandsInItsPlace:
- "Your edit of it stands in its place, so Put Back moves that edit to the Trash first, where History keeps it."
+ case .replacementStandsInItsPlace:
+ "Another version of it is in its place now, so Put Back moves that one to the Trash first, where History keeps it."
}
}
}
@@ -289,7 +289,9 @@ private struct HistoryRecordRow: View {
private var notes: [RecordNote] {
var notes: [RecordNote] = record.sharedStorage == true ? [.sharedStorage] : []
if place == .inTrash, AudioDrivers.isOne(record.originalURL) { notes.append(.loadsAfterARestart) }
- if place == .inTrash, record.trashedItem.editStandsInItsPlace { notes.append(.editStandsInItsPlace) }
+ if place == .inTrash, record.trashedItem.replacementStandsInItsPlace {
+ notes.append(.replacementStandsInItsPlace)
+ }
return notes
}
diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swift
index ec0b9bbf..da68cc95 100644
--- a/Peel/Views/Presentation.swift
+++ b/Peel/Views/Presentation.swift
@@ -301,8 +301,8 @@ extension RestoreFailure {
String(localized: "macOS lets Peel put back another developer’s app only with App Management. Allow Peel in System Settings > Privacy & Security > App Management, then try again.")
case .notPermitted: String(localized: "macOS didn’t allow it.")
case .failed(let message): FixedSentence.translated(message)
- case .editStays(let reason):
- String(localized: "The edit in its place couldn’t move to the Trash first, so nothing changed.") + " "
+ case .replacementStays(let reason):
+ String(localized: "The version now in its place couldn’t move to the Trash first, so nothing changed.") + " "
+ reason.explanation
}
}