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 lists packages kept in Application Support

Țugui Dragoș25b2541b5dc9
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 3840af0a..40df5d89 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -73361,6 +73361,112 @@
}
}
},
+ "Not selected: this is in a folder an app keeps in Application Support, and the app may still need it." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nevybráno: tento soubor je ve složce, kterou si aplikace uchovává v Application Support, a aplikace ho možná ještě potřebuje."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nicht ausgewählt: Dieses Objekt befindet sich in einem Ordner, den eine App in Application Support aufbewahrt, und die App benötigt es möglicherweise noch."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Sin seleccionar: está en una carpeta que una app guarda en Application Support, y puede que la app aún lo necesite."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Non sélectionné : ce fichier se trouve dans un dossier qu’une app conserve dans Application Support, et l’app en a peut-être encore besoin."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Non selezionato: si trova in una cartella che un’app conserva in Application Support, e l’app potrebbe averne ancora bisogno."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未選択: これはアプリがApplication Supportに保存しているフォルダ内にあり、そのアプリがまだ必要としている可能性があります。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "선택되지 않음: 이 파일은 앱이 Application Support에 보관하는 폴더에 있으며, 해당 앱에 아직 필요할 수 있습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Niet geselecteerd: dit staat in een map die een app in Application Support bewaart, en de app heeft het misschien nog nodig."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nie zaznaczono: ten plik jest w folderze, który aplikacja przechowuje w Application Support, i może go ona jeszcze potrzebować."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Não selecionado: este item está em uma pasta que um app guarda em Application Support, e o app pode ainda precisar dele."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Neselectat: acest fișier se află într‑un dosar pe care o aplicație îl păstrează în Application Support, iar aplicația ar putea avea încă nevoie de el."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Не выбрано: этот файл находится в папке, которую приложение хранит в Application Support, и приложению он, возможно, еще нужен."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Inte markerad: den här filen ligger i en mapp som en app har i Application Support, och appen kanske fortfarande behöver den."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Seçilmedi: bu dosya, bir uygulamanın Application Support içinde tuttuğu bir klasörde ve uygulamanın ona hâlâ ihtiyacı olabilir."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Не вибрано: цей файл міститься в папці, яку програма зберігає в Application Support, і, можливо, він ще потрібен цій програмі."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未选择:此文件位于某个App保存在Application Support中的文件夹内,该App可能仍需要它。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未選取:此項目位於某個App在Application Support中保存的檔案夾,而且該App可能仍需要它。"
+ }
+ }
+ }
+ },
"Not selected: this is in iCloud Drive, so moving it to the Trash removes it from iCloud and from your other devices." : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
index 7aff7b26..3c53e183 100644
--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift
@@ -277,6 +277,7 @@ extension HoldBack {
case .inTheCloud: "in iCloud Drive, so moving it removes it from every device"
case .openInAProgram: "open in a program right now, which may still be downloading it"
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"
}
}
}
diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
index 10a4b535..16be4587 100644
--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift
@@ -71,6 +71,8 @@ public enum HoldBack: String, Sendable, Hashable {
case openInAProgram
/// A download that changed within the last day, which may still be going.
case changedRecently
+ /// An installer package in a folder an app keeps in Application Support, which the app may still need.
+ case keptByAnApp
/// 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 c81443b3..4a702a90 100644
--- a/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift
@@ -147,6 +147,15 @@ public enum Installers {
openFiles: openFiles
)
items += await firmwareFiles(home: home, exclusions: exclusions, minimumSize: minimumSize, measure: measure)
+ items += await packagesKeptByApps(
+ home: home,
+ installedApps: installedApps,
+ exclusions: exclusions,
+ minimumSize: minimumSize,
+ measure: measure,
+ isInTheCloud: isInTheCloud,
+ openFiles: openFiles
+ )
let backupFolder = home.appending(path: "Library/Application Support/MobileSync/Backup", directoryHint: .isDirectory)
let readable = canList(backupFolder)
@@ -366,6 +375,45 @@ public enum Installers {
return items
}
+ /// Installer packages in `~/Library/Application Support`, up to three levels down, never inside a package or in
+ /// the device backups. Each is matched by its name to an installed app, or else by the folder it sits in.
+ static func packagesKeptByApps(
+ home: URL,
+ installedApps: [InstalledApp],
+ exclusions: Exclusions,
+ minimumSize: Int64,
+ measure: LeftoverScanner.Measure,
+ isInTheCloud: (URL) -> Bool,
+ openFiles: OpenFiles
+ ) async -> [InstallerItem] {
+ let support = home.appending(path: "Library/Application Support", directoryHint: .isDirectory)
+ var items: [InstallerItem] = []
+ var folders: [(url: URL, depth: Int, owner: String?)] = [(support, 1, nil)]
+ while let (folder, depth, owner) = folders.popLast() {
+ for url in files(in: folder) {
+ guard !Task.isCancelled else { return items }
+ guard ["pkg", "mpkg"].contains(url.pathExtension.lowercased()) else {
+ if depth < 3, url.isRealFolder, !FileSize.isDataless(url),
+ (try? url.resourceValues(forKeys: [.isPackageKey]).isPackage) != true,
+ depth > 1 || url.lastPathComponent != "MobileSync" {
+ folders.append((url, depth + 1, owner ?? url.lastPathComponent))
+ }
+ continue
+ }
+ guard !exclusions.excludes(url) else { continue }
+ let (size, seen) = await measured(url, by: measure)
+ guard isWorthARow(size, minimumSize) else { continue }
+ let place = Folder(url: folder, isSharedWithEveryone: false)
+ let heldBack = heldBack(url, seen: seen, in: place, isInTheCloud: isInTheCloud, openFiles: openFiles)
+ let named = installedApp(for: url, in: installedApps) == nil ? owner : nil
+ items.append(appInstaller(
+ at: url, size: size, heldBack: heldBack ?? .keptByAnApp, installedApps: installedApps, named: named
+ ))
+ }
+ }
+ return items
+ }
+
/// Makes the item for an unfinished download. One that changed within `stillDownloading` may still be going, so
/// it is left for the person to choose.
static func incompleteDownload(at url: URL, size: Int64?, heldBack: HoldBack?) -> InstallerItem {
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift
index fb508686..585bb742 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift
@@ -14,6 +14,7 @@ struct InstallersTests {
for index in 1...3 {
try directory.directory("Applications/Install macOS \(index).app/Contents")
try directory.file("Library/iTunes/iPhone Software Updates/iPhone \(index).ipsw", bytes: 16)
+ try directory.file("Library/Application Support/Tool \(index)/Update.pkg", bytes: 16)
}
let unanswered = Unanswered()
@@ -272,6 +273,27 @@ struct InstallersTests {
#expect(items["Archive.zip.part"]?.heldBack == .changedRecently)
}
+ @Test func findsPackagesKeptInApplicationSupportAndLeavesThemToChoose() async throws {
+ let directory = try TemporaryDirectory()
+ try directory.file("Library/Application Support/org.example.Studio/Updates/Studio-2.4.pkg", bytes: 400_000)
+ try directory.file("Library/Application Support/Toolbox/Installer.mpkg/Contents/Archive", bytes: 400_000)
+ try directory.file("Library/Application Support/Toolbox/a/b/Deeper.pkg", bytes: 400_000)
+ try directory.file("Library/Application Support/MobileSync/Backup.pkg", bytes: 400_000)
+ try directory.file("Library/Application Support/Toolbox/notes.txt", bytes: 400_000)
+ try directory.directory("Applications")
+
+ let scan = await Installers.scan(
+ installedApps: [app("Studio", bundleIdentifier: "org.example.Studio")], home: directory.url,
+ root: directory.url, exclusions: .none, minimumSize: 100_000, measure: LeftoverScanner.walk,
+ openFiles: OpenFiles(excluding: nil)
+ )
+
+ let items = Dictionary(uniqueKeysWithValues: scan.items(in: .appInstaller).map { ($0.name, $0) })
+ #expect(Set(items.keys) == ["Studio-2.4.pkg", "Installer.mpkg"])
+ #expect(items["Studio-2.4.pkg"]?.installedApp == "Studio")
+ #expect(items.values.allSatisfy { $0.heldBack == .keptByAnApp })
+ }
+
@Test func aDownloadAProgramStillHasOpenIsLeftForThePersonToChoose() async throws {
let directory = try TemporaryDirectory()
let downloading = try directory.file("Downloads/Tool-1.dmg", bytes: 400_000)
diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swift
index 423f1135..dc47ebc6 100644
--- a/Peel/Views/Presentation.swift
+++ b/Peel/Views/Presentation.swift
@@ -216,6 +216,8 @@ extension HoldBack {
"Not selected: a program has this open right now, and may still be downloading it."
case .changedRecently:
"Not selected: this changed in the last day, so it may still be downloading."
+ case .keptByAnApp:
+ "Not selected: this is in a folder an app keeps in Application Support, and the app may still need it."
}
}
}
diff --git a/README.md b/README.md
index 5a05d74f..f67bfcd5 100644
--- a/README.md
+++ b/README.md
@@ -117,8 +117,9 @@ Peel is free and open source, and it speaks English and 17 other languages.
neither are installed packages (a Python environment, `vendor`, Terraform's `.terraform`) or a folder like `target`
whose name says nothing on its own.
- **Duplicates:** files and whole folders with identical contents, compared with SHA-256. One copy is always kept.
-- **Installers and Backups:** installers of apps you already have, macOS installers, device firmware, downloads a
- browser never finished, and what your iPhone backups hold. Nothing is selected for you.
+- **Installers and Backups:** installers of apps you already have, including packages an app keeps in Application
+ Support, macOS installers, device firmware, downloads a browser never finished, and what your iPhone backups hold.
+ Nothing is selected for you.
- **iCloud Drive:** files already safe in iCloud that are also downloaded to this Mac. Remove Downloads, as in
Finder, 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. The caches and logs apps keep for every account,