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.

Installers and Backups leaves an installer in iCloud Drive unselected

Țugui Dragoșf93c46eb1d1b
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index ed17b043..4adb432c 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -70253,6 +70253,112 @@
}
}
},
+ "Not selected: this is in iCloud Drive, so moving it to the Trash removes it from iCloud and from your other devices." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nevybráno: tento soubor je na iCloud Drivu, takže přesunutím do koše ho odstraníte z iCloudu i z vašich ostatních zařízení."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nicht ausgewählt: Dieses Objekt liegt in iCloud Drive, daher wird es aus iCloud und von deinen anderen Geräten entfernt, wenn du es in den Papierkorb legst."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sin seleccionar: está en iCloud Drive, así que trasladarlo a la papelera lo elimina de iCloud y de tus otros dispositivos."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Non sélectionné : ce fichier se trouve dans iCloud Drive ; le placer dans la corbeille le supprime donc d’iCloud et de vos autres appareils."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Non selezionato: questo file si trova su iCloud Drive, quindi, se lo sposti nel Cestino, viene rimosso da iCloud e dagli altri tuoi dispositivi."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未選択: これはiCloud Driveにあるため、ゴミ箱に入れると、iCloudからも、ほかのデバイスからも削除されます。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "선택되지 않음: 이 파일은 iCloud Drive에 있으므로 휴지통으로 이동하면 iCloud는 물론 다른 기기에서도 삭제됩니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Niet geselecteerd: dit staat op iCloud Drive, dus als je het naar de prullenmand verplaatst, verdwijnt het uit iCloud en van je andere apparaten."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nie zaznaczono: ten plik jest na iCloud Drive, więc po przeniesieniu do Kosza zostanie usunięty z iCloud i z Twoich pozostałych urządzeń."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Não selecionado: este item está no iCloud Drive, então, se você o mover para o Lixo, ele será removido do iCloud e dos seus outros dispositivos."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Neselectat: acest fișier se află pe iCloud Drive, așa că mutarea lui în Coș îl elimină de pe iCloud și de pe celelalte dispozitive ale dvs."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Не выбрано: этот файл находится в iCloud Drive, поэтому, если переместить его в Корзину, он будет удален из iCloud и с других Ваших устройств."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Inte markerad: den här filen ligger i iCloud Drive, så om du flyttar den till papperskorgen tas den bort från iCloud och från dina andra enheter."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Seçilmedi: bu dosya, iCloud Drive’da olduğu için Çöp Sepeti’ne taşınırsa iCloud’dan ve diğer aygıtlarınızdan silinir."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Не вибрано: цей файл зберігається в iCloud Drive, тож переміщення в Смітник прибирає його з iCloud і з інших ваших пристроїв."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未选择:此文件位于iCloud云盘中,因此将它移到废纸篓后,它会从iCloud和你的其他设备中删除。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未選取:此項目位於「iCloud雲碟」中,因此丟到「垃圾桶」會將它從iCloud和你的其他裝置上移除。"
+ }
+ }
+ }
+ },
"Not selected: this project is too large for Peel to tell when it last changed." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
index fc1e66ab..3348f434 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
@@ -274,6 +274,7 @@ extension HoldBack {
case .keptByMacOS: "a cache macOS keeps for itself"
case .openedFromMail: "an attachment opened from Mail, which may be the only copy"
case .crashReport: "a crash report, which the app's developer may still ask for"
+ case .inTheCloud: "in iCloud Drive, so moving it removes it from every device"
}
}
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
index 86aab0d8..33496c1f 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
@@ -65,6 +65,8 @@ public enum HoldBack: String, Sendable, Hashable {
case openedFromMail
/// A report macOS wrote when the app crashed, which its developer may still ask for.
case crashReport
+ /// A file in iCloud Drive, which moving to the Trash removes from every device.
+ case inTheCloud
/// True when the item cannot be selected at all, rather than only left unselected.
public var cannotBeMoved: Bool {
diff --git a/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift b/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift
index 629cae9a..d6a6c578 100644
--- a/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift
@@ -81,7 +81,8 @@ public enum Installers {
exclusions: Exclusions,
minimumSize: Int64,
measure: LeftoverScanner.Measure,
- canList: (URL) -> AccessState = FullDiskAccess.canList
+ canList: (URL) -> AccessState = FullDiskAccess.canList,
+ isInTheCloud: (URL) -> Bool = { $0.isInTheCloud }
) async -> InstallerScan {
var items: [InstallerItem] = []
var unreadable: [URL] = []
@@ -95,8 +96,9 @@ public enum Installers {
let isInstaller = installerExtensions.contains(suffix)
let isArchive = suffix == "zip"
guard isInstaller || isArchive || firmwareExtensions.contains(suffix), !exclusions.excludes(url), !Task.isCancelled else { continue }
- let (size, heldBack) = await measured(url, by: measure)
+ let (size, seen) = await measured(url, by: measure)
guard isWorthARow(size, minimumSize) else { continue }
+ let heldBack = isInTheCloud(url) ? .inTheCloud : seen
if isArchive {
guard let app = appInside(zip: url) else { continue }
items.append(appInstaller(at: url, size: size, heldBack: heldBack, installedApps: installedApps, named: app))
@@ -114,7 +116,8 @@ public enum Installers {
in: [root.appending(path: "Applications", directoryHint: .isDirectory)] + downloads,
exclusions: exclusions,
minimumSize: minimumSize,
- measure: measure
+ measure: measure,
+ isInTheCloud: isInTheCloud
)
items += await firmwareFiles(home: home, exclusions: exclusions, minimumSize: minimumSize, measure: measure)
@@ -241,13 +244,19 @@ public enum Installers {
return words
}
- static func macOSInstallers(in folders: [URL], exclusions: Exclusions, minimumSize: Int64, measure: LeftoverScanner.Measure) async -> [InstallerItem] {
+ static func macOSInstallers(
+ in folders: [URL],
+ exclusions: Exclusions,
+ minimumSize: Int64,
+ measure: LeftoverScanner.Measure,
+ isInTheCloud: (URL) -> Bool
+ ) async -> [InstallerItem] {
var items: [InstallerItem] = []
for folder in folders {
for url in files(in: folder) where url.pathExtension.lowercased() == "app" && url.lastPathComponent.hasPrefix("Install macOS") {
guard !Task.isCancelled else { return items }
guard !exclusions.excludes(url) else { continue }
- let (size, heldBack) = await measured(url, by: measure)
+ let (size, seen) = await measured(url, by: measure)
guard isWorthARow(size, minimumSize) else { continue }
let version = AppInspector.infoDictionary(in: url.appending(path: "Contents", directoryHint: .isDirectory))?["CFBundleShortVersionString"] as? String
items.append(InstallerItem(
@@ -260,7 +269,7 @@ public enum Installers {
isReadOnly: false,
notes: version.map { [.version($0)] } ?? [],
requiresPrivileges: FileAccess.requiresPrivilegesToRemove(url),
- heldBack: heldBack
+ heldBack: isInTheCloud(url) ? .inTheCloud : seen
))
}
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift
index 3b162642..4fc1b623 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift
@@ -133,6 +133,26 @@ struct InstallersTests {
#expect(scan.items.map(\.name) == ["Tool-2.dmg"])
}
+ @Test func anInstallerInICloudDriveIsLeftForThePersonToChoose() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("Documents/Tool-2.dmg", bytes: 400_000)
+ try directory.directory("Documents/Install macOS Tahoe.app/Contents")
+ try directory.file("Documents/Install macOS Tahoe.app/Contents/MacOS/app", bytes: 400_000)
+ try directory.file("Desktop/Other-3.dmg", bytes: 400_000)
+ let documents = PathPattern.comparablePath(of: directory.url.appending(path: "Documents"))
+
+ let scan = await Installers.scan(
+ installedApps: [], home: directory.url, root: directory.url, exclusions: .none, minimumSize: 100_000,
+ measure: LeftoverScanner.walk,
+ isInTheCloud: { PathPattern.comparablePath(of: $0.deletingLastPathComponent()) == documents }
+ )
+
+ let heldBack = Dictionary(uniqueKeysWithValues: scan.items.map { ($0.name, $0.heldBack) })
+ #expect(heldBack["Tool-2.dmg"] == .inTheCloud)
+ #expect(heldBack["Install macOS Tahoe"] == .inTheCloud)
+ #expect(heldBack["Other-3.dmg"] == .some(nil))
+ }
+
@Test func findsMacOSInstallersAndDeviceFirmware() async throws {
let directory = try TemporaryDirectory()
try directory.file("Applications/Install macOS Tahoe.app/Contents/MacOS/app", bytes: 400_000)
diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swift
index b0a5c039..b5808af1 100644
--- a/Peel/Views/Presentation.swift
+++ b/Peel/Views/Presentation.swift
@@ -208,6 +208,8 @@ extension HoldBack {
"Not selected: Mail keeps a copy here of each attachment you open, and one you edited may exist nowhere else."
case .crashReport:
"Not selected: a report macOS wrote when the app crashed, which its developer may still ask you for."
+ case .inTheCloud:
+ "Not selected: this is in iCloud Drive, so moving it to the Trash removes it from iCloud and from your other devices."
}
}
}