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
Recommend only an installer that can be downloaded again
Țugui Dragoș2dd0f271ce9f
diff --git a/GUIDE.md b/GUIDE.mdindex a3c7628b..30b12896 100644--- a/GUIDE.md+++ b/GUIDE.md@@ -64,7 +64,8 @@ Space shows what fills your disk, area by area, and what each area is.installer inside, whether you have that app or not; packages an app keeps in Application Support; macOSinstallers, device firmware, downloads a browser never finished, updates apps downloaded and keep until theyinstall them, and what your iPhone backups hold. A disk image can also be one you made to keep files in, so look- before you select it. Nothing is selected for you.+ before you select it. Nothing is selected for you, and Select Recommended takes only what you can download again:+ an installed app's installer or one in Downloads, never an encrypted disk image.- **iCloud Drive:** files already safe in iCloud that are also downloaded to this Mac. Remove Downloads, as inFinder, takes away only the copy on this Mac: each file stays in iCloud and downloads again when you open it.- **Space:** what's taking up room, and which app it belongs to. What an app manages itself, such as Docker's disk,diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 5f9be1f7..8f2dda86 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -86654,6 +86654,112 @@}}},+ "Not selected: an encrypted disk image holds what you put in it." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nevybráno: šifrovaný obraz disku obsahuje to, co jste do něj uložili."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nicht ausgewählt: Eine verschlüsselte Image-Datei enthält, was du darin abgelegt hast."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Sin seleccionar: una imagen de disco encriptada contiene lo que has guardado en ella."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Non sélectionné : une image disque chiffrée contient ce que vous y avez mis."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Non selezionato: un’immagine disco crittografata contiene ciò che ci hai messo dentro."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未選択: 暗号化されたディスクイメージには、自分で入れたものが含まれています。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "선택되지 않음: 암호화된 디스크 이미지에는 사용자가 넣어 둔 항목이 들어 있습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Niet geselecteerd: een versleutelde schijfkopie bevat wat je erin hebt gezet."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nie zaznaczono: zaszyfrowany obraz dysku zawiera to, co w nim przechowujesz."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Não selecionado: uma imagem de disco criptografada guarda o que você colocou nela."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Neselectat: o imagine de disc criptată conține ceea ce ați pus în ea."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Не выбрано: зашифрованный образ диска хранит то, что Вы в него поместили."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Inte markerad: en krypterad skivavbild innehåller det som du har lagt i den."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Seçilmedi: şifreli bir disk görüntüsü, içine koyduğunuz şeyleri tutar."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Не вибрано: зашифрований образ диска містить те, що ви в нього поклали."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未选择:已加密的磁盘映像中存放的是你放入的内容。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未選取:已加密的磁碟映像檔存放的是你放入其中的內容。"+ }+ }+ }+ },"Not selected: it belongs to an app macOS keeps, so it is in use." : {"localizations" : {"cs" : {@@ -88774,6 +88880,112 @@}}},+ "Not selected: this isn’t in Downloads and isn’t an installed app’s installer, so it may be yours rather than something you can download again." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nevybráno: tento soubor není ve složce Stahování a není to instalátor nainstalované aplikace, takže může být váš vlastní, a ne něco, co si můžete znovu stáhnout."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nicht ausgewählt: Dieses Objekt liegt nicht in „Downloads“ und ist nicht der Installer einer installierten App, daher ist es möglicherweise deines und nicht etwas, das du erneut laden kannst."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Sin seleccionar: no está en Descargas ni es el instalador de una app instalada, así que puede que sea tuyo y no algo que puedas volver a descargar."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Non sélectionné : ce fichier ne se trouve pas dans le dossier Téléchargements et n’est pas le programme d’installation d’une app installée ; il s’agit donc peut-être de l’un de vos fichiers, et non de quelque chose que vous pouvez télécharger à nouveau."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Non selezionato: non si trova nella cartella Download e non è l’installer di un’app installata, quindi potrebbe essere un tuo file anziché qualcosa che puoi scaricare di nuovo."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未選択: これは“ダウンロード”フォルダになく、インストール済みのアプリのインストーラでもないため、再ダウンロードできるものではなく、自分のファイルである可能性があります。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "선택되지 않음: 이 파일은 다운로드 폴더에 있지 않고 설치된 앱의 설치 프로그램도 아니므로, 다시 다운로드할 수 있는 항목이 아니라 사용자의 파일일 수 있습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Niet geselecteerd: dit staat niet in de map Downloads en is geen installatieprogramma van een geïnstalleerde app, dus het is misschien van jou en niet iets wat je opnieuw kunt downloaden."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nie zaznaczono: ten plik nie jest w folderze Pobrane rzeczy ani nie jest instalatorem zainstalowanej aplikacji, więc może to być Twój plik, a nie coś, co możesz pobrać ponownie."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Não selecionado: este item não está em Downloads e não é o instalador de um app instalado, então pode ser seu, e não algo que você possa baixar de novo."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Neselectat: acest fișier nu se află în Descărcări și nu este programul de instalare al unei aplicații instalate, așa că ar putea fi al dvs., nu ceva ce puteți descărca din nou."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Не выбрано: этот файл находится не в папке «Загрузки» и не является установщиком ни одного из установленных приложений, поэтому он может быть Вашим собственным, а не тем, что можно загрузить снова."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Inte markerad: den här filen ligger inte i Hämtade filer och är inte installeraren för en installerad app, så den kan vara din egen snarare än något som du kan hämta igen."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Seçilmedi: bu dosya İndirilenler klasöründe değil ve yüklü bir uygulamanın yükleyicisi de değil, bu nedenle yeniden indirebileceğiniz bir şey yerine size ait bir dosya olabilir."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Не вибрано: цей файл не міститься в папці «Викачане» й не є інсталятором інстальованої програми, тож, можливо, він ваш, а не з тих, що можна викачати знову."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未选择:此文件不在“下载”文件夹中,也不是已安装App的安装器,因此可能是你自己的文件,而不是可以重新下载的内容。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未選取:此項目不在「下載項目」中,也不是已安裝App的安裝程式,因此可能是你自己的,而不是你可以重新下載的項目。"+ }+ }+ }+ },"Not selected: this may hold mail kept only on this Mac, such as a local or POP account’s. Once the Trash is emptied, it’s gone for good unless you have a backup." : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex e4231f35..d80dd80a 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -337,6 +337,8 @@ extension HoldBack {case .changedRecently: "changed in the last day, so it may still be downloading"case .keptByAnApp: "in an app's folder in Application Support, and the app may still need it"case .appIsRunning: "its app is running and may install this update when it quits"+ case .mayBeTheOnlyCopy: "outside Downloads and no installed app's installer, so it may be yours, not a download"+ case .encryptedImage: "an encrypted disk image, which holds what you put in it"}}}diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swiftindex 0cabe68c..3d50872d 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift@@ -97,6 +97,10 @@ public enum HoldBack: String, Sendable, Hashable {case keptByAnApp/// An update whose app is running, which may install it when it quits.case appIsRunning+ /// An installer outside Downloads that is no installed app's, which may be the person's own rather than a download.+ case mayBeTheOnlyCopy+ /// An encrypted disk image, which holds what the person put in it.+ case encryptedImage/// True when the item cannot be selected at all, rather than only left unselected: the guard or the helper/// would refuse to move it.@@ -116,7 +120,8 @@ public enum HoldBack: String, Sendable, Hashable {.holdsDocuments, .holdsALibrary, .holdsAWallet, .holdsAPasswordDatabase, .holdsLocalMail,.holdsMessageHistory, .holdsPasswordsOrCodes, .holdsVPNConnections, .holdsKeys, .holdsWorkKeptInACache,.insideAnotherAppsFolder, .beyondTheHelper, .leftToItsUninstaller, .keptByMacOS, .openedFromMail,- .inTheCloud, .openInAProgram, .changedRecently, .keptByAnApp, .appIsRunning: true+ .inTheCloud, .openInAProgram, .changedRecently, .keptByAnApp, .appIsRunning, .mayBeTheOnlyCopy,+ .encryptedImage: true}}diff --git a/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift b/Packages/PeelCore/Sources/PeelCore/Space/Installers.swiftindex e2c21153..89669120 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift@@ -124,13 +124,17 @@ public enum Installers {var items: [InstallerItem] = []var unreadable: [URL] = []let places = ["Downloads", "Desktop", "Documents", "Public"].map {- Folder(url: home.appending(path: $0, directoryHint: .isDirectory), isSharedWithEveryone: false)+ Folder(+ url: home.appending(path: $0, directoryHint: .isDirectory),+ isSharedWithEveryone: false,+ holdsDownloads: $0 == "Downloads"+ )} + [Folder(url: root.appending(path: "Users/Shared", directoryHint: .isDirectory), isSharedWithEveryone: true)]var folders: [Folder] = []for place in places {if canList(place.url) == .missing { unreadable.append(place.url) }folders += [place] + subfolders(of: place.url).map {- Folder(url: $0, isSharedWithEveryone: place.isSharedWithEveryone)+ Folder(url: $0, isSharedWithEveryone: place.isSharedWithEveryone, holdsDownloads: place.holdsDownloads)}}@@ -151,21 +155,15 @@ public enum Installers {items.append(incompleteDownload(at: url, size: size, heldBack: heldBack))} else if isArchive {guard let inside = installerInside(zip: url) else { continue }- items.append(- appInstaller(- at: url,- size: size,- heldBack: heldBack,- installedApps: installedApps,- named: inside- )+ let installer = appInstaller(+ at: url, size: size, heldBack: heldBack, installedApps: installedApps, named: inside)+ items.append(unlessItCanBeDownloadedAgain(installer, in: folder))+ } else if isInstaller {+ let installer = appInstaller(at: url, size: size, heldBack: heldBack, installedApps: installedApps)+ items.append(unlessItCanBeDownloadedAgain(installer, in: folder))} else {- items.append(- isInstaller- ? appInstaller(at: url, size: size, heldBack: heldBack, installedApps: installedApps)- : firmware(at: url, size: size, heldBack: heldBack)- )+ items.append(firmware(at: url, size: size, heldBack: heldBack))}}}@@ -222,10 +220,12 @@ public enum Installers {)}- /// A folder the scan looks in, and whether it belongs to every account on this Mac rather than to this one.+ /// A folder the scan looks in, whether it belongs to every account on this Mac rather than to this one, and+ /// whether it is Downloads or a folder inside it.struct Folder {let url: URLlet isSharedWithEveryone: Bool+ var holdsDownloads = false}/// The folders directly inside `place` that the scan looks in too, where a browser or a chat app keeps its@@ -252,6 +252,24 @@ public enum Installers {return folder.isSharedWithEveryone ? .sharedWithEveryone : nil}+ /// Holds back an app installer that may not be downloaded again: one outside Downloads that is no installed app's+ /// may be the person's own image, and an encrypted disk image holds what they put in it.+ private static func unlessItCanBeDownloadedAgain(_ installer: InstallerItem, in folder: Folder) -> InstallerItem {+ guard installer.heldBack == nil else { return installer }+ var installer = installer+ if isEncryptedImage(installer.url) {+ installer.heldBack = .encryptedImage+ } else if installer.installedApp == nil, !folder.holdsDownloads {+ installer.heldBack = .mayBeTheOnlyCopy+ }+ return installer+ }++ /// Whether `url` is an encrypted disk image: one that `hdiutil create -encryption` makes begins with `encrcdsa`.+ static func isEncryptedImage(_ url: URL) -> Bool {+ url.pathExtension.lowercased() == "dmg" && BoundedRead.prefix(of: url, count: 8) == Data("encrcdsa".utf8)+ }+/// What measuring `url` gave: its size, and why what it saw leaves the item for the person to choose.private static func measured(_ url: URL,diff --git a/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swiftindex 35373b0e..0187853c 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift@@ -158,6 +158,52 @@ struct InstallersTests {#expect(installers.allSatisfy { !$0.isReadOnly })}+ @Test func recommendsOnlyAnInstallerThatCanBeDownloadedAgain() async throws {+ let directory = try TemporaryDirectory()+ let unknown = try directory.file("Downloads/Unknown-1.dmg", bytes: 400_000)+ let known = try directory.file("Documents/VisualStudioCode-1.99.0.dmg", bytes: 400_000)+ let photos = try directory.file("Documents/Photos 2019.dmg", bytes: 400_000)+ let backup = try directory.file("Desktop/Backup.iso", bytes: 400_000)+ let secrets = try directory.directory("Downloads").appending(path: "Secrets.dmg")+ try makeEncryptedImage(at: secrets)+ try directory.directory("Applications")++ let scan = await Installers.scan(+ installedApps: [app("Visual Studio Code", bundleIdentifier: "com.microsoft.VSCode")],+ home: directory.url,+ root: directory.url,+ minimumSize: 100_000+ )++ let heldBack = Dictionary(uniqueKeysWithValues: scan.items.map { ($0.name, $0.heldBack) })+ #expect(heldBack["Unknown-1.dmg"] == .some(nil))+ #expect(heldBack["VisualStudioCode-1.99.0.dmg"] == .some(nil))+ #expect(heldBack["Photos 2019.dmg"] == .mayBeTheOnlyCopy)+ #expect(heldBack["Backup.iso"] == .mayBeTheOnlyCopy)+ #expect(heldBack["Secrets.dmg"] == .encryptedImage)+ let rows = scan.items.selectableRows(canUseHelper: false)+ #expect(Set(rows.recommended.map { PathPattern.comparablePath(of: $0) })+ == Set([unknown, known].map { PathPattern.comparablePath(of: $0) }))+ #expect(Set(rows.leftToTheClick.map { PathPattern.comparablePath(of: $0) })+ == Set([photos, backup, secrets].map { PathPattern.comparablePath(of: $0) }))+ }++ private func makeEncryptedImage(at url: URL) throws {+ let process = Process()+ process.executableURL = URL(filePath: "/usr/bin/hdiutil")+ process.arguments = [+ "create", "-quiet", "-encryption", "AES-128", "-stdinpass", "-size", "1m", "-fs", "APFS", "-volname", "Probe",+ url.path(percentEncoded: false),+ ]+ let password = Pipe()+ process.standardInput = password+ try process.run()+ password.fileHandleForWriting.write(Data("probe".utf8))+ try password.fileHandleForWriting.close()+ process.waitUntilExit()+ #expect(process.terminationStatus == 0)+ }+@Test func findsADiskImageInTheISOFormat() async throws {let directory = try TemporaryDirectory()try directory.file("Downloads/ubuntu-24.04-desktop-arm64.iso", bytes: 400_000)@@ -244,7 +290,7 @@ struct InstallersTests {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)+ try directory.file("Downloads/Other-3.dmg", bytes: 400_000)let documents = PathPattern.comparablePath(of: directory.url.appending(path: "Documents"))let scan = await Installers.scan(diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex b458ccc2..d95f584f 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -270,6 +270,10 @@ extension HoldBack {"Not selected: this is in a folder an app keeps in Application Support, and the app may still need it."case .appIsRunning:"Not selected: the app is running and may install this update when it quits."+ case .mayBeTheOnlyCopy:+ "Not selected: this isn’t in Downloads and isn’t an installed app’s installer, so it may be yours rather than something you can download again."+ case .encryptedImage:+ "Not selected: an encrypted disk image holds what you put in it."}}}diff --git a/SAFETY.md b/SAFETY.mdindex 24327b39..e2e9d6f9 100644--- a/SAFETY.md+++ b/SAFETY.md@@ -239,6 +239,8 @@ Never selected for you, even when found:- A file in iCloud Drive, which the Trash would take from every device, and a file a program has open right now.- An installer package an app keeps in Application Support, which the app may still need, and an update whose app isrunning, which may install it when the app quits.+- An encrypted disk image, and a disk image, package, or archive outside Downloads that isn't an installed app's+ installer, which may be your own rather than something you can download again.A folder macOS would not let Peel read, and a folder Peel could not measure in time, are not selected either. Both areshown with their size as "Unknown", never as zero, in every tool and in History once they are moved: a folder too big to