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
Show iCloud Drive's page by default only where it is set up
Țugui Dragoș192381682278
diff --git a/GUIDE.md b/GUIDE.mdindex a1fbaf8a..c25089fe 100644--- a/GUIDE.md+++ b/GUIDE.md@@ -351,8 +351,8 @@ Privacy, which says what Peel sends and every place it may contact, and Helper.- **Shortcuts:** actions that open a page in Peel for you to look at. None of them removes anything.- **Sidebar:** turn off the tools you don't use in Settings, and they leave the sidebar. The View menu andShortcuts still open them. Home, Applications, and History always stay. Background Items, Extensions, Plug-ins,- Build Artifacts, Intel Software, and Terminal start turned off, and Homebrew starts on only when Homebrew is- installed; what you turn on or off stays so.+ Build Artifacts, Intel Software, and Terminal start turned off, Homebrew starts on only when Homebrew is installed,+ and iCloud Drive only when it is set up on this Mac; what you turn on or off stays so.- **The `peel` command:** most of what Peel does, from Terminal, as [The `peel` command](#the-peel-command) says.With Show in Menu Bar on, Peel's menu bar item lists what each tool found the last time it looked, a line per tooldiff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 337648b1..42b708df 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -231345,6 +231345,113 @@}}},+ "iCloud Drive isn’t set up for this account on this Mac." : {+ "comment" : "On the iCloud Drive page, under Nothing to Free, when the person has never turned on iCloud Drive on this Mac.",+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud Drive není pro tento účet v tomto Macu nastavený."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud Drive ist für diesen Benutzeraccount auf diesem Mac nicht eingerichtet."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud Drive no está configurado para esta cuenta en este Mac."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud Drive n’est pas configuré pour ce compte sur ce Mac."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud Drive non è configurato per questo account su questo Mac."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "このMacのこのアカウントでは、iCloud Driveが設定されていません。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "이 Mac의 이 계정에는 iCloud Drive가 설정되어 있지 않습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud Drive is niet ingesteld voor deze account op deze Mac."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Usługa iCloud Drive nie jest skonfigurowana dla tego konta na tym Macu."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "O iCloud Drive não está configurado para esta conta neste Mac."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud Drive nu este configurat pentru acest cont pe acest Mac."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud Drive не настроен для этой учетной записи на этом Mac."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud Drive har inte ställts in för det här kontot på den här datorn."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud Drive bu Mac’te bu hesap için ayarlanmamış."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "iCloud Drive не налаштовано для цього облікового запису на цьому Mac."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "这台Mac上的此账户尚未设置iCloud云盘。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "此帳號尚未在這部Mac上設定「iCloud雲碟」。"+ }+ }+ }+ },"iPhone and iPad Backups" : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCore/Space/CloudStorage.swift b/Packages/PeelCore/Sources/PeelCore/Space/CloudStorage.swiftindex 84e0bc18..8a24dbea 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/CloudStorage.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/CloudStorage.swift@@ -39,6 +39,8 @@ public struct CloudScan: Sendable {/// `CloudStorage.minimumSize` on disk, yet removing it would free less.public var sharedDownloads = 0public var folders: [CloudFolder] = []+ /// iCloud Drive was never set up for this account: the folder iCloud keeps in the home isn't there.+ public var isNotSetUp = falsepublic enum CutShort: Sendable, Equatable {/// The walk ran out of time or was stopped before it read everything.@@ -161,7 +163,8 @@ public enum CloudStorage {cutShort: finished == nil ? .ranOutOfTime : collected.cutShort,couldNotRead: collected.couldNotRead,sharedDownloads: collected.sharedDownloads,- folders: folders(of: collected.files, home: home)+ folders: folders(of: collected.files, home: home),+ isNotSetUp: !isSetUp(home: home))}@@ -346,6 +349,11 @@ public enum CloudStorage {}}+ /// Whether iCloud Drive was ever set up for the account of `home`: iCloud makes `~/Library/Mobile Documents` then.+ public static func isSetUp(home: URL = .homeDirectory) -> Bool {+ home.appending(path: "Library/Mobile Documents", directoryHint: .isDirectory).isRealFolder+ }+/// Whether `url`, or a folder it sits in below `root`, is named as a password database or a wallet's keys are.static func holdsSecrets(_ url: URL, below root: URL) -> Bool {let names = PathComponents.of(url.path(percentEncoded: false))diff --git a/Packages/PeelCore/Tests/PeelCoreTests/CloudStorageTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/CloudStorageTests.swiftindex 6e3b07a3..178a8a0c 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/CloudStorageTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/CloudStorageTests.swift@@ -261,6 +261,19 @@ struct CloudStorageTests {#expect(held["prices.csv"] == .some(nil))}+ /// Without the folder iCloud keeps in the home, iCloud Drive was never set up for this account, which the page+ /// says rather than that nothing was found.+ @Test func saysWhenICloudDriveIsNotSetUp() async throws {+ let directory = try TemporaryDirectory()++ #expect(!CloudStorage.isSetUp(home: directory.url))+ #expect(await CloudStorage.downloaded(home: directory.url).isNotSetUp)++ try directory.directory("Library/Mobile Documents/com~apple~CloudDocs")+ #expect(CloudStorage.isSetUp(home: directory.url))+ #expect(await CloudStorage.downloaded(home: directory.url).isNotSetUp == false)+ }+/// A folder kept only in the cloud, which no test can make, is named to the walk.@Test func neverLooksIntoAFolderThatLivesOnlyInTheCloud() throws {let directory = try TemporaryDirectory()diff --git a/Peel/Model/CloudLibrary.swift b/Peel/Model/CloudLibrary.swiftindex d95c9a25..70a06cfe 100644--- a/Peel/Model/CloudLibrary.swift+++ b/Peel/Model/CloudLibrary.swift@@ -33,6 +33,8 @@ final class CloudLibrary {private(set) var couldNotRead = false/// The downloads left out because another copy on this Mac shares their space, so removing them frees nothing.private(set) var sharedDownloads = 0+ /// iCloud Drive was never set up for this account.+ private(set) var isNotSetUp = falsevar selectedURLs: Set<URL> = [] {didSet { updateSelectedSize() }}@@ -98,6 +100,7 @@ final class CloudLibrary {cutShort = found.cutShortcouldNotRead = found.couldNotReadsharedDownloads = found.sharedDownloads+ isNotSetUp = found.isNotSetUpselectedURLs.formIntersection(Set(found.files.map(\.url)))}diff --git a/Peel/Navigation/Tool.swift b/Peel/Navigation/Tool.swiftindex 0b23d34e..91054387 100644--- a/Peel/Navigation/Tool.swift+++ b/Peel/Navigation/Tool.swift@@ -109,27 +109,31 @@ extension Tool {}/// Whether the sidebar shows this tool to a person who never chose: what someone who uninstalls and frees space- /// rarely needs starts off, and Homebrew shows while Homebrew is installed.- func isShownByDefault(homebrewIsInstalled: Bool) -> Bool {+ /// rarely needs starts off, Homebrew shows while Homebrew is installed, and iCloud Drive while it is set up.+ func isShownByDefault(homebrewIsInstalled: Bool, hasICloudDrive: Bool) -> Bool {switch self {case .backgroundItems, .extensions, .plugins, .projects, .intel, .terminal: falsecase .homebrew: homebrewIsInstalled+ case .cloud: hasICloudDrivedefault: true}}/// The tools the sidebar leaves out: those the person chose to, and those never chosen that start off.- static func hidden(by choices: SidebarChoices, homebrewIsInstalled: Bool) -> Set<Tool> {+ static func hidden(by choices: SidebarChoices, homebrewIsInstalled: Bool, hasICloudDrive: Bool) -> Set<Tool> {Set(allCases.filter { tool in- let byDefault = tool.isShownByDefault(homebrewIsInstalled: homebrewIsInstalled)+ let byDefault = tool.isShownByDefault(+ homebrewIsInstalled: homebrewIsInstalled, hasICloudDrive: hasICloudDrive+ )return tool.canBeHidden && !choices.shows(tool.rawValue, byDefault: byDefault)})}- /// `hidden(by:homebrewIsInstalled:)` as the sidebar, Settings, and the menu bar panel all ask it, so they agree:- /// Homebrew's page shows while Homebrew is on this Mac, even when Peel won't run it, so the page can say why.+ /// `hidden(by:homebrewIsInstalled:hasICloudDrive:)` as the sidebar, Settings, and the menu bar panel all ask it,+ /// so they agree: Homebrew's page shows while Homebrew is on this Mac, even when Peel won't run it, so the page+ /// can say why.static func hidden(by choices: SidebarChoices, homebrew: HomebrewLibrary) -> Set<Tool> {- hidden(by: choices, homebrewIsInstalled: homebrew.isOnThisMac)+ hidden(by: choices, homebrewIsInstalled: homebrew.isOnThisMac, hasICloudDrive: CloudStorage.isSetUp())}}diff --git a/Peel/Views/Cloud/CloudView.swift b/Peel/Views/Cloud/CloudView.swiftindex 2834c34e..8654c10b 100644--- a/Peel/Views/Cloud/CloudView.swift+++ b/Peel/Views/Cloud/CloudView.swift@@ -150,7 +150,11 @@ struct CloudView: View {Label("Nothing to Free", systemImage: "checkmark.seal")} description: {VStack(spacing: 8) {- Text("Peel found no file here that is safely in iCloud and big enough to be worth freeing.")+ if cloud.isNotSetUp {+ Text("iCloud Drive isn’t set up for this account on this Mac.")+ } else {+ Text("Peel found no file here that is safely in iCloud and big enough to be worth freeing.")+ }sharedDownloadsNote}}diff --git a/PeelTests/ToolDefaultsTests.swift b/PeelTests/ToolDefaultsTests.swiftnew file mode 100644index 00000000..21f73e31--- /dev/null+++ b/PeelTests/ToolDefaultsTests.swift@@ -0,0 +1,13 @@+import Foundation+@testable import Peel+import Testing++struct ToolDefaultsTests {+ /// iCloud Drive's page starts on only where iCloud Drive is set up, as Homebrew's does only with Homebrew.+ @Test func showsICloudDriveByDefaultOnlyWhereItIsSetUp() {+ #expect(Tool.cloud.isShownByDefault(homebrewIsInstalled: true, hasICloudDrive: true))+ #expect(!Tool.cloud.isShownByDefault(homebrewIsInstalled: true, hasICloudDrive: false))+ #expect(!Tool.homebrew.isShownByDefault(homebrewIsInstalled: false, hasICloudDrive: true))+ #expect(Tool.duplicates.isShownByDefault(homebrewIsInstalled: false, hasICloudDrive: false))+ }+}