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.

Remove Downloads says what it left as it was

Țugui Dragoșb95bf76fa29c
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 0367ae3e..253b20bf 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -62722,6 +62722,112 @@
}
}
},
+ "No downloads were removed." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Žádné stažené položky se neodstranily."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Es wurden keine Downloads entfernt."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "No se ha eliminado ninguna descarga."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Aucun téléchargement n’a été retiré."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Non è stato rimosso nessun download."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "ダウンロードしたものを何も削除できませんでした。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "아무 다운로드도 제거하지 않았습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Er zijn geen downloads verwijderd."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nie usunięto żadnych pobranych rzeczy."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nenhum download foi removido."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nicio descărcare nu a fost eliminată."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ни одна загрузка не удалена."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Inga hämtningar togs bort."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "İndirilenlerden hiçbiri kaldırılmadı."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Жодне викачування не вилучено."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "没有移除任何下载。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "沒有移除任何下載項目。"
+ }
+ }
+ }
+ },
"No duplicates were found, but Peel couldn’t look in ^[%lld folder](inflect: true), so there may be some there. Give Peel Full Disk Access, or choose folders it can read." : {
"localizations" : {
"cs" : {
@@ -102023,6 +102129,112 @@
}
}
},
+ "Some downloads couldn’t be removed." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Některé stažené položky nelze odstranit."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Einige Downloads konnten nicht entfernt werden."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "No se han podido eliminar algunas descargas."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Impossible de retirer certains téléchargements."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Impossibile rimuovere alcuni download."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "ダウンロードしたものの一部を削除できませんでした。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "일부 다운로드를 제거할 수 없습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sommige downloads konden niet worden verwijderd."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nie udało się usunąć niektórych pobranych rzeczy."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Não foi possível remover alguns downloads."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Unele descărcări nu au putut fi eliminate."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Некоторые загрузки не удалось удалить."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Vissa hämtningar kunde inte tas bort."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Bazı indirilenler kaldırılamadı."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Деякі викачування не вдалося вилучити."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "部分下载未能移除。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "部分下載項目無法移除。"
+ }
+ }
+ }
+ },
"Some folders couldn’t be read" : {
"localizations" : {
"cs" : {
diff --git a/Peel/Views/Cloud/CloudView.swift b/Peel/Views/Cloud/CloudView.swift
index 7bd8b19a..7b9ddf2a 100644
--- a/Peel/Views/Cloud/CloudView.swift
+++ b/Peel/Views/Cloud/CloudView.swift
@@ -10,6 +10,8 @@ struct CloudView: View {
@Environment(HomeModel.self) private var home
@State private var isConfirming = false
@State private var freed: BarNotice?
+ /// What the last Remove Downloads left as it was, which an alert tells, since the list moves on without it.
+ @State private var leftAlone: LeftAlone?
@State private var isRescanning = false
@State private var searchText = ""
@@ -23,6 +25,24 @@ struct CloudView: View {
.listRowSeparator(.hidden)
RemovalsHeldBanner()
+ if !cloud.refusals.isEmpty {
+ Section {
+ ForEach(cloud.refusals) { refusal in
+ VStack(alignment: .leading, spacing: 2) {
+ Text(refusal.url.abbreviatedPath)
+ .font(.callout)
+ .lineLimit(1)
+ .truncationMode(.middle)
+ Text(refusal.explanation)
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ }
+ }
+ } header: {
+ heading("Still Here", "These were left as they are, with the reason beside each one.")
+ }
+ }
+
if !listed.isEmpty {
Section {
ForEach(Array(listed.enumerated()), id: \.element.id) { index, file in
@@ -54,24 +74,6 @@ struct CloudView: View {
}
}
}
-
- if !cloud.refusals.isEmpty {
- Section {
- ForEach(cloud.refusals) { refusal in
- VStack(alignment: .leading, spacing: 2) {
- Text(refusal.url.abbreviatedPath)
- .font(.callout)
- .lineLimit(1)
- .truncationMode(.middle)
- Text(refusal.explanation)
- .font(.caption)
- .foregroundStyle(.secondary)
- }
- }
- } header: {
- heading("Still Here", "These were left as they are, with the reason beside each one.")
- }
- }
}
.dimmedWhileBusy(cloud.isScanning)
.columnSearch(text: $searchText, prompt: "Search iCloud Drive", when: cloud.files?.isEmpty == false)
@@ -134,6 +136,9 @@ struct CloudView: View {
Button("Remove Downloads") {
Task {
let bytes = await cloud.freeSelected()
+ if !cloud.refusals.isEmpty {
+ leftAlone = LeftAlone(freed: bytes, refusals: cloud.refusals)
+ }
guard bytes > 0 else { return }
freed = BarNotice(figure: bytes.byteCount, words: "Freed")
AccessibilityNotification.Announcement(AttributedString(localized: "Freed \(bytes.byteCount) on this Mac.")).post()
@@ -143,6 +148,15 @@ struct CloudView: View {
} message: {
Text("This frees \(cloud.selectedSize.byteCount). Nothing is deleted from iCloud: the files stay there, Finder still lists them, and they download again when you open them.")
}
+ .alert(
+ leftAlone?.freed == 0 ? Text("No downloads were removed.") : Text("Some downloads couldn’t be removed."),
+ isPresented: Binding(get: { leftAlone != nil }, set: { if !$0 { leftAlone = nil } }),
+ presenting: leftAlone
+ ) { _ in
+ Button("OK", role: .cancel) {}
+ } message: { leftAlone in
+ Text(verbatim: leftAlone.message)
+ }
.task {
guard cloud.files == nil, !cloud.isScanning, !cloud.scanRun.wasStopped else { return }
await cloud.refresh()
@@ -177,3 +191,20 @@ struct CloudView: View {
}
}
}
+
+/// The files one Remove Downloads left as they were, and what it freed.
+private struct LeftAlone {
+ let freed: Int64
+ let refusals: [CloudRefusal]
+
+ /// The first few files with the reason each stayed, as the alert after a removal lists them. Still Here, at the
+ /// top of the page, lists them all.
+ var message: String {
+ var lines = refusals.prefix(RemovalFailureAlert.mostListed).map { "\($0.url.abbreviatedPath)\n\($0.explanation)" }
+ let rest = refusals.count - lines.count
+ if rest > 0 {
+ lines.append(String(inflecting: "And ^[\(rest) more item](inflect: true)."))
+ }
+ return lines.joined(separator: "\n\n")
+ }
+}
diff --git a/Peel/Views/RemovalFailureAlert.swift b/Peel/Views/RemovalFailureAlert.swift
index 86d56a96..7a444dfb 100644
--- a/Peel/Views/RemovalFailureAlert.swift
+++ b/Peel/Views/RemovalFailureAlert.swift
@@ -7,7 +7,7 @@ import SwiftUI
/// alerts cannot be up at once.
struct RemovalFailureAlert: ViewModifier {
/// How many items the alert lists by path. The rest are only counted, to keep the alert short.
- private static let mostListed = 4
+ static let mostListed = 4
@Environment(RemovalOutcome.self) private var outcome
@Environment(\.openSettings) private var openSettings