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
Leave a download Keep Downloaded took since the scan
Țugui Dragoșb8923d5f0f4b
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex f8eeaa96..eb0573ae 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -81114,6 +81114,112 @@}}},+ "Keep Downloaded is on for it in Finder, so iCloud would download it again." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Ve Finderu je u něj zapnutá volba „Zachovat stažené“, takže by ho iCloud znovu stáhl."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "„Laden und behalten“ ist für diese Datei im Finder aktiviert, daher würde iCloud sie erneut laden."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Tiene activado “Conservar en dispositivo” en el Finder, así que iCloud lo volvería a descargar."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "« Conserver le téléchargement » est activé pour ce fichier dans le Finder : iCloud le téléchargerait donc à nouveau."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nel Finder è attivo “Conserva scaricato” per questo file, quindi iCloud lo scaricherebbe di nuovo."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Finderで“ダウンロード済みを保持”がオンになっているため、削除してもiCloudが再びダウンロードします。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Finder에서 이 파일에 ‘다운로드 항목 유지’가 켜져 있으므로 iCloud가 다시 다운로드하게 됩니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "'Bewaar download' staat in Finder aan voor dit bestand, dus iCloud zou het opnieuw downloaden."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "W Finderze jest dla tego pliku włączona opcja „Zachowuj pobrane”, więc iCloud pobrałby go ponownie."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "A opção “Manter Downloads” está ativada para ele no Finder, então o iCloud o baixaria de novo."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "În Finder, opțiunea „Păstrați descărcat” este activată pentru acest fișier, așa că iCloud l‑ar descărca din nou."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Для этого файла в Finder включен параметр «Оставить в загрузках», поэтому iCloud снова загрузил бы его."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "”Behåll hämtningar” är aktiverat för den i Finder, så iCloud skulle hämta den igen."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Finder’da bu dosya için “İndirileni Tut” açık, bu yüzden iCloud onu yeniden indirirdi."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Для цього файлу у Finder увімкнено «Не передавати у хмару», тож iCloud знову його викачає."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "它在“访达”中已设为“保留下载”,因此iCloud会重新下载它。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "它已在Finder中設為「保留已下載項目」,因此iCloud會再次下載它。"+ }+ }+ }+ },"Keep Peel Open" : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCore/Space/CloudStorage.swift b/Packages/PeelCore/Sources/PeelCore/Space/CloudStorage.swiftindex 0eff7c80..3307f0f2 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/CloudStorage.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/CloudStorage.swift@@ -63,6 +63,8 @@ public struct CloudRefusal: Sendable, Hashable, Identifiable {case excluded/// A program holds the file, as the wallpaper is held, so macOS could not lock it to free its copy.case inUse+ /// Keep Downloaded came on for it since the scan, so iCloud would download it again.+ case keptDownloaded/// macOS refused to free the file. The value is the error message it gave.case failed(String)}@@ -427,6 +429,16 @@ public enum CloudStorage {}}+ /// Whether Keep Downloaded is on for `url` or for a folder it sits in.+ static func isKeptDownloaded(_ url: URL, isPinned: (URL) -> Bool) -> Bool {+ var place = url+ while place.pathComponents.count > 1 {+ if isPinned(place) { return true }+ place = place.deletingLastPathComponent()+ }+ return false+ }+/// Frees the local copies of `files`, one at a time. Each file is checked again first, against `exclusions` as/// they are now as well: the list may have been on screen for hours, and a file edited since then may exist in/// its newest form only on the local disk.@@ -441,7 +453,8 @@ public enum CloudStorage {_ files: [CloudFile],exclusions: Exclusions,isSafe: (URLResourceValues) -> Bool,- evict: (URL) throws -> Void = { try FileManager.default.evictUbiquitousItem(at: $0) }+ evict: (URL) throws -> Void = { try FileManager.default.evictUbiquitousItem(at: $0) },+ isPinned: (URL) -> Bool = isPinned(_:)) async -> CloudFreeing {var done = CloudFreeing()for file in files {@@ -473,6 +486,11 @@ public enum CloudStorage {done.refused.append(CloudRefusal(url: file.url, reason: .changedSinceScan))continue}+ // A row the scan already held back for this is the person's choice.+ if file.heldBack != .keptDownloaded, isKeptDownloaded(file.url, isPinned: isPinned) {+ done.refused.append(CloudRefusal(url: file.url, reason: .keptDownloaded))+ continue+ }do {try evict(file.url)done.freed.append(file)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/CloudStorageTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CloudStorageTests.swiftindex fb01b4af..9bc3942e 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/CloudStorageTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/CloudStorageTests.swift@@ -847,6 +847,33 @@ struct CloudStorageTests {#expect(done.refused.isEmpty)}+ @Test func leavesADownloadKeepDownloadedTookSinceTheScan() async throws {+ let directory = try TemporaryDirectory()+ func download(_ path: String, heldBack: HoldBack? = nil) throws -> CloudFile {+ let url = try directory.file("Library/Mobile Documents/com~apple~CloudDocs/\(path)", bytes: 2_000)+ let modified = try url.resourceValues(forKeys: [.contentModificationDateKey]).contentModificationDate+ return CloudFile(+ url: url, name: url.lastPathComponent, container: "iCloud Drive", size: 2_000, modified: modified,+ heldBack: heldBack+ )+ }+ let itself = try download("Kept.pdf")+ let inAFolder = try download("Trip/Plans/route.pdf")+ let inAnAppsFolder = try download("App.pdf", heldBack: .inAnAppsICloudFolder)+ let chosenKnowingly = try download("Chosen.pdf", heldBack: .keptDownloaded)+ let plain = try download("Plain.pdf")+ let pinned: Set = ["Kept.pdf", "Trip", "App.pdf", "Chosen.pdf"]++ let done = await CloudStorage.free(+ [itself, inAFolder, inAnAppsFolder, chosenKnowingly, plain], exclusions: .none, isSafe: { _ in true },+ evict: { _ in }, isPinned: { pinned.contains($0.lastPathComponent) }+ )++ #expect(done.freed == [chosenKnowingly, plain])+ #expect(done.refused.map(\.url) == [itself.url, inAFolder.url, inAnAppsFolder.url])+ #expect(Set(done.refused.map(\.reason)) == [.keptDownloaded])+ }+@Test func countsEachFileItFrees() async throws {let directory = try TemporaryDirectory()let files = try downloads(3, in: directory)diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex 07f721e9..c6893319 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -297,6 +297,7 @@ extension CloudRefusal {case .changedSinceScan: String(localized: "It isn’t as it was when Peel looked at it: it may have been edited, stopped syncing, or been freed already, so Peel left it alone.")case .excluded: String(localized: "Excluded in Settings")case .inUse: String(localized: "A program is using it, as the wallpaper is used, so macOS couldn’t remove its download. Try again once nothing uses it.")+ case .keptDownloaded: String(localized: "Keep Downloaded is on for it in Finder, so iCloud would download it again.")case .failed(let message): message}}