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
Say why iCloud kept a download, and test the Keep Downloaded reader
Țugui Dragoșb7c5d51a2fec
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 3d8b829f..1beda442 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -243537,6 +243537,112 @@}}},+ "iCloud keeps this download on this Mac, so it can’t be removed." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud tuto staženou položku v tomto Macu uchovává, takže ji nelze odstranit."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud behält diesen Download auf diesem Mac, daher kann er nicht entfernt werden."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud conserva esta descarga en este Mac, así que no se puede eliminar."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud conserve ce téléchargement sur ce Mac : il ne peut donc pas être retiré."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud conserva questo download su questo Mac, quindi non può essere rimosso."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "このダウンロードしたものはiCloudがこのMacに保持しているため、削除できません。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud가 이 다운로드를 이 Mac에 유지하므로 제거할 수 없습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud bewaart deze download op deze Mac, dus die kan niet worden verwijderd."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud zachowuje tę pobraną rzecz na tym Macu, więc nie można jej usunąć."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "O iCloud mantém este download neste Mac, então ele não pode ser removido."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud păstrează această descărcare pe acest Mac, așa că nu poate fi eliminată."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud хранит эту загрузку на этом Mac, поэтому ее нельзя удалить."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud behåller den här hämtningen på den här datorn, så den kan inte tas bort."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud bu indirileni bu Mac’te tutuyor, bu yüzden kaldırılamaz."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud зберігає це викачування на цьому Mac, тож його не можна вилучити."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud将此下载保留在这台Mac上,因此无法将其移除。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud會將此下載項目保留在這部Mac上,因此無法移除。"+ }+ }+ }+ },"iPhone and iPad Backups" : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCore/Space/CloudStorage.swift b/Packages/PeelCore/Sources/PeelCore/Space/CloudStorage.swiftindex 6398773a..5d6ab6be 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/CloudStorage.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/CloudStorage.swift@@ -1,3 +1,4 @@+internal import FileProviderpublic import Foundationimport Synchronizationinternal import PeelPrivileged@@ -65,6 +66,8 @@ public struct CloudRefusal: Sendable, Hashable, Identifiable {case inUse/// Keep Downloaded came on for it since the scan, so iCloud would download it again.case keptDownloaded+ /// iCloud marked it as a download it keeps.+ case notRemovable/// macOS refused to free the file. The value is the error message it gave.case failed(String)}@@ -541,9 +544,22 @@ public enum CloudStorage {: FileManager.default.displayName(atPath: url.path(percentEncoded: false))}- /// Why freeing a file failed: `NSFileLockingError` when a program holds it, and macOS's own message otherwise.+ /// Why freeing a file failed, from what `NSFileProviderError.h` says of an eviction, and macOS's own message for+ /// anything else. A program holding the file answers `NSFileLockingError` or `EBUSY`.static func reason(for error: any Error) -> CloudRefusal.Reason {- (error as? CocoaError)?.code == .fileLocking ? .inUse : .failed(error.localizedDescription)+ let error = error as NSError+ switch (error.domain, error.code) {+ case (NSCocoaErrorDomain, CocoaError.fileLocking.rawValue), (NSPOSIXErrorDomain, Int(EBUSY)):+ return .inUse+ case (NSFileProviderErrorDomain, NSFileProviderError.Code.unsyncedEdits.rawValue):+ return .changedSinceScan+ case (NSFileProviderErrorDomain, NSFileProviderError.Code.nonEvictable.rawValue):+ return .notRemovable+ case (NSFileProviderErrorDomain, NSFileProviderError.Code.nonEvictableChildren.rawValue):+ return error.underlyingErrors.first.map(reason(for:)) ?? .notRemovable+ default:+ return .failed(error.localizedDescription)+ }}/// A document saved as a package, which iCloud keeps as one item: what removing its download frees, what it takesdiff --git a/Packages/PeelCore/Tests/PeelCoreTests/CloudStorageTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CloudStorageTests.swiftindex 74eb6d5f..7c109855 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/CloudStorageTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/CloudStorageTests.swift@@ -1,3 +1,4 @@+import FileProviderimport Foundation@testable import PeelCoreimport Synchronization@@ -950,6 +951,49 @@ struct CloudStorageTests {#expect(CloudStorage.reason(for: other) == .failed(other.localizedDescription))}+ @Test func saysWhyFileProviderKeptADownload() {+ func refusal(_ code: NSFileProviderError.Code, because underlying: [NSError] = []) -> NSError {+ NSError(+ domain: NSFileProviderErrorDomain, code: code.rawValue,+ userInfo: underlying.isEmpty ? [:] : [NSMultipleUnderlyingErrorsKey: underlying]+ )+ }++ #expect(CloudStorage.reason(for: refusal(.unsyncedEdits)) == .changedSinceScan)+ #expect(CloudStorage.reason(for: refusal(.nonEvictable)) == .notRemovable)+ #expect(CloudStorage.reason(for: refusal(.nonEvictableChildren)) == .notRemovable)+ #expect(+ CloudStorage.reason(for: refusal(.nonEvictableChildren, because: [refusal(.unsyncedEdits)]))+ == .changedSinceScan+ )+ let busy = NSError(domain: NSPOSIXErrorDomain, code: Int(EBUSY))+ #expect(CloudStorage.reason(for: busy) == .inUse)+ #expect(CloudStorage.reason(for: refusal(.nonEvictableChildren, because: [busy])) == .inUse)+ }++ @Test func readsKeepDownloadedFromTheFileItself() throws {+ let directory = try TemporaryDirectory()+ func file(_ name: String, carrying attribute: String? = nil) throws -> URL {+ let url = try directory.file(name, bytes: 1)+ if let attribute {+ #expect(setxattr(url.path(percentEncoded: false), attribute, nil, 0, 0, 0) == 0)+ }+ return url+ }+ let withFlags = try file("flags.pdf", carrying: "com.apple.fileprovider.pinned#PX")+ let withoutFlags = try file("plain.pdf", carrying: "com.apple.fileprovider.pinned")+ let another = try file("other.pdf", carrying: "com.apple.fileprovider.pinnedElsewhere")+ let none = try file("none.pdf")+ let link = directory.url.appending(path: "link.pdf")+ try FileManager.default.createSymbolicLink(at: link, withDestinationURL: withFlags)++ #expect(CloudStorage.isPinned(withFlags))+ #expect(CloudStorage.isPinned(withoutFlags))+ #expect(!CloudStorage.isPinned(another))+ #expect(!CloudStorage.isPinned(none))+ #expect(!CloudStorage.isPinned(link))+ }+/// The desktop picture is open for as long as it is shown, so the scan says which file it is.@Test func theDesktopPictureIsMarked() throws {let directory = try TemporaryDirectory()diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex c6893319..5b941f63 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -298,6 +298,7 @@ extension CloudRefusal {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 .notRemovable: String(localized: "iCloud keeps this download on this Mac, so it can’t be removed.")case .failed(let message): message}}