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
Count the container folders under Where rather than list them all
Țugui Dragoș546c9ee2411b
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 8ad9db18..83160eb7 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -4444,6 +4444,698 @@}}},+ "%@ inside ^[%lld app container](inflect: true)" : {+ "localizations" : {+ "cs" : {+ "variations" : {+ "plural" : {+ "few" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ uvnitř %2$lld kontejnerů aplikací"+ }+ },+ "many" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ uvnitř %2$lld kontejneru aplikace"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ uvnitř %2$lld kontejneru aplikace"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ uvnitř %2$lld kontejnerů aplikací"+ }+ }+ }+ }+ },+ "de" : {+ "variations" : {+ "plural" : {+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ in %2$lld App-Container"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ in %2$lld App-Containern"+ }+ }+ }+ }+ },+ "en" : {+ "stringUnit" : {+ "state" : "new",+ "value" : "%1$@ inside ^[%2$lld app container](inflect: true)"+ }+ },+ "es" : {+ "variations" : {+ "plural" : {+ "many" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dentro de %2$lld de contenedores de apps"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dentro de %2$lld contenedor de app"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dentro de %2$lld contenedores de apps"+ }+ }+ }+ }+ },+ "fr" : {+ "variations" : {+ "plural" : {+ "many" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dans %2$lld de conteneurs d’apps"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dans %2$lld conteneur d’app"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dans %2$lld conteneurs d’apps"+ }+ }+ }+ }+ },+ "it" : {+ "variations" : {+ "plural" : {+ "many" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ in %2$lld di contenitori di app"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ in %2$lld contenitore di app"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ in %2$lld contenitori di app"+ }+ }+ }+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%2$lld個のアプリコンテナ内の%1$@"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "앱 컨테이너 %2$lld개 안의 %1$@"+ }+ },+ "nl" : {+ "variations" : {+ "plural" : {+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ in %2$lld appcontainer"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ in %2$lld appcontainers"+ }+ }+ }+ }+ },+ "pl" : {+ "variations" : {+ "plural" : {+ "few" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ w %2$lld kontenerach aplikacji"+ }+ },+ "many" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ w %2$lld kontenerach aplikacji"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ w %2$lld kontenerze aplikacji"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ w %2$lld kontenera aplikacji"+ }+ }+ }+ }+ },+ "pt" : {+ "variations" : {+ "plural" : {+ "many" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dentro de %2$lld de contêineres de apps"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dentro de %2$lld contêiner de app"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dentro de %2$lld contêineres de apps"+ }+ }+ }+ }+ },+ "ro" : {+ "variations" : {+ "plural" : {+ "few" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ din %2$lld containere de aplicații"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ din %2$lld container de aplicație"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ din %2$lld de containere de aplicații"+ }+ }+ }+ }+ },+ "ru" : {+ "variations" : {+ "plural" : {+ "few" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ в %2$lld контейнерах приложений"+ }+ },+ "many" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ в %2$lld контейнерах приложений"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ в %2$lld контейнере приложения"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ в %2$lld контейнера приложения"+ }+ }+ }+ }+ },+ "sv" : {+ "variations" : {+ "plural" : {+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ i %2$lld appbehållare"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ i %2$lld appbehållare"+ }+ }+ }+ }+ },+ "tr" : {+ "variations" : {+ "plural" : {+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%2$lld uygulama kapsayıcısının içinde %1$@"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%2$lld uygulama kapsayıcısının içinde %1$@"+ }+ }+ }+ }+ },+ "uk" : {+ "variations" : {+ "plural" : {+ "few" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ у %2$lld контейнерах програм"+ }+ },+ "many" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ у %2$lld контейнерах програм"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ у %2$lld контейнері програми"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ у %2$lld контейнера програми"+ }+ }+ }+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%2$lld个App容器内,共%1$@"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%2$lld個App容器內的%1$@"+ }+ }+ }+ },+ "%@ inside ^[%lld group container](inflect: true)" : {+ "localizations" : {+ "cs" : {+ "variations" : {+ "plural" : {+ "few" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ uvnitř %2$lld skupinových kontejnerů"+ }+ },+ "many" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ uvnitř %2$lld skupinového kontejneru"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ uvnitř %2$lld skupinového kontejneru"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ uvnitř %2$lld skupinových kontejnerů"+ }+ }+ }+ }+ },+ "de" : {+ "variations" : {+ "plural" : {+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ in %2$lld Gruppencontainer"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ in %2$lld Gruppencontainern"+ }+ }+ }+ }+ },+ "en" : {+ "stringUnit" : {+ "state" : "new",+ "value" : "%1$@ inside ^[%2$lld group container](inflect: true)"+ }+ },+ "es" : {+ "variations" : {+ "plural" : {+ "many" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dentro de %2$lld de contenedores de grupo"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dentro de %2$lld contenedor de grupo"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dentro de %2$lld contenedores de grupo"+ }+ }+ }+ }+ },+ "fr" : {+ "variations" : {+ "plural" : {+ "many" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dans %2$lld de conteneurs de groupe"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dans %2$lld conteneur de groupe"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dans %2$lld conteneurs de groupe"+ }+ }+ }+ }+ },+ "it" : {+ "variations" : {+ "plural" : {+ "many" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ in %2$lld di contenitori di gruppo"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ in %2$lld contenitore di gruppo"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ in %2$lld contenitori di gruppo"+ }+ }+ }+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%2$lld個のグループコンテナ内の%1$@"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "그룹 컨테이너 %2$lld개 안의 %1$@"+ }+ },+ "nl" : {+ "variations" : {+ "plural" : {+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ in %2$lld groepscontainer"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ in %2$lld groepscontainers"+ }+ }+ }+ }+ },+ "pl" : {+ "variations" : {+ "plural" : {+ "few" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ w %2$lld kontenerach grup"+ }+ },+ "many" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ w %2$lld kontenerach grup"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ w %2$lld kontenerze grupy"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ w %2$lld kontenera grupy"+ }+ }+ }+ }+ },+ "pt" : {+ "variations" : {+ "plural" : {+ "many" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dentro de %2$lld de contêineres de grupo"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dentro de %2$lld contêiner de grupo"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ dentro de %2$lld contêineres de grupo"+ }+ }+ }+ }+ },+ "ro" : {+ "variations" : {+ "plural" : {+ "few" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ din %2$lld containere de grup"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ din %2$lld container de grup"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ din %2$lld de containere de grup"+ }+ }+ }+ }+ },+ "ru" : {+ "variations" : {+ "plural" : {+ "few" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ в %2$lld групповых контейнерах"+ }+ },+ "many" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ в %2$lld групповых контейнерах"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ в %2$lld групповом контейнере"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ в %2$lld группового контейнера"+ }+ }+ }+ }+ },+ "sv" : {+ "variations" : {+ "plural" : {+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ i %2$lld gruppbehållare"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ i %2$lld gruppbehållare"+ }+ }+ }+ }+ },+ "tr" : {+ "variations" : {+ "plural" : {+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%2$lld grup kapsayıcısının içinde %1$@"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%2$lld grup kapsayıcısının içinde %1$@"+ }+ }+ }+ }+ },+ "uk" : {+ "variations" : {+ "plural" : {+ "few" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ у %2$lld групових контейнерах"+ }+ },+ "many" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ у %2$lld групових контейнерах"+ }+ },+ "one" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ у %2$lld груповому контейнері"+ }+ },+ "other" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%1$@ у %2$lld групового контейнера"+ }+ }+ }+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%2$lld个群组容器内,共%1$@"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "%2$lld個群組容器內的%1$@"+ }+ }+ }+ },"%@ is already installed" : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift b/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swiftindex 6c7e8820..c8e3031d 100644--- a/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift+++ b/Packages/PeelCore/Sources/PeelCore/Space/SpaceReport.swift@@ -49,6 +49,21 @@ public struct SpaceItem: Sendable, Hashable, Identifiable {public var isReadOnly: Bool {if case .readOnly = handling { true } else { false }}++ /// The folders an area has in each of many containers, which every Mac has hundreds of, so they are counted.+ public struct ContainerFolders: Sendable, Hashable {+ public let parent: URL+ public let folders: [String]+ public let containers: Int+ public let areGroups: Bool+ }++ public var inContainers: [ContainerFolders] = []++ /// The folders of `urls` that are named one by one.+ public var listedPlaces: [URL] {+ urls.filter { url in !inContainers.contains { SpaceInventory.container(of: url, in: $0.parent) != nil } }+ }}public struct SpaceReport: Sendable {@@ -622,7 +637,11 @@ public enum SpaceInventory {root: URL,simctlRuntimeHelp help: String?) -> SpaceItem {- SpaceItem(+ let counted = [+ ("Library/Containers", definition.containerFolders, false),+ ("Library/Group Containers", definition.groupContainerFolder.map { [$0] } ?? [], true),+ ]+ return SpaceItem(id: definition.id,category: definition.category,urls: urls,@@ -634,7 +653,23 @@ public enum SpaceInventory {onlyFilesIn: definition.onlyFilesIn(home: home, root: root),keepsItsFolders: definition.keepsItsFolders,commands: definition.commands.filter { $0.isKnown(simctlRuntimeHelp: help) }.map(\.line),- managingAppIsMissing: definition.managedBy.map { !$0.oneIsOnThisMac } ?? false+ managingAppIsMissing: definition.managedBy.map { !$0.oneIsOnThisMac } ?? false,+ inContainers: counted.compactMap { path, folders, areGroups in+ let parent = home.appending(path: path, directoryHint: .isDirectory)+ let containers = Set(urls.compactMap { container(of: $0, in: parent) })+ guard !folders.isEmpty, !containers.isEmpty else { return nil }+ return SpaceItem.ContainerFolders(+ parent: parent, folders: folders.map { URL(filePath: $0).lastPathComponent },+ containers: containers.count, areGroups: areGroups+ )+ })}++ /// The name of the folder directly in `parent` that holds `url`.+ static func container(of url: URL, in parent: URL) -> String? {+ let path = PathComponents.of(PathPattern.comparablePath(of: url))+ let folder = PathComponents.of(PathPattern.comparablePath(of: parent))+ return path.count > folder.count && path.starts(with: folder) ? path[folder.count] : nil+ }}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swiftindex 88742cf9..8fa58d43 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/SpaceInventoryTests.swift@@ -235,6 +235,40 @@ struct SpaceInventoryTests {#expect(logs.size.known < 400_000)}+ @Test func countsTheFoldersAnAreaHasInContainersRatherThanNamingEach() async throws {+ let directory = try TemporaryDirectory()+ for index in 0..<3 {+ let container = "home/Library/Containers/org.example.app\(index)/Data"+ try directory.file("\(container)/Library/Caches/blob")+ try directory.file("\(container)/tmp/blob")+ try directory.file("\(container)/Library/Logs/run.log")+ }+ try directory.file("home/Library/Containers/org.example.only-tmp/Data/tmp/blob")+ try directory.file("home/Library/Group Containers/group.org.example/Library/Caches/blob")+ try directory.file("home/Library/Logs/org.example.tool/run.log")+ let home = directory.url.appending(path: "home", directoryHint: .isDirectory)+ let containers = home.appending(path: "Library/Containers", directoryHint: .isDirectory)+ let groups = home.appending(path: "Library/Group Containers", directoryHint: .isDirectory)++ let report = await SpaceInventory.scan(+ home: home, root: directory.url.appending(path: "root", directoryHint: .isDirectory),+ minimumSize: 1, measure: LeftoverScanner.walk+ )++ let caches = try #require(report.items.first { $0.id == "container-caches" })+ #expect(caches.urls.count == 8)+ #expect(caches.listedPlaces.isEmpty)+ #expect(caches.inContainers == [+ SpaceItem.ContainerFolders(parent: containers, folders: ["Caches", "tmp"], containers: 4, areGroups: false),+ SpaceItem.ContainerFolders(parent: groups, folders: ["Caches"], containers: 1, areGroups: true),+ ])+ let logs = try #require(report.items.first { $0.id == "logs" })+ #expect(logs.listedPlaces.map(\.lastPathComponent) == ["Logs"])+ #expect(logs.inContainers == [+ SpaceItem.ContainerFolders(parent: containers, folders: ["Logs"], containers: 3, areGroups: false),+ ])+ }+@Test func measuresAFewPlacesOfAnAreaAtATime() async throws {let directory = try TemporaryDirectory()for index in 0..<8 {diff --git a/Peel/Views/Space/SpaceDetailView.swift b/Peel/Views/Space/SpaceDetailView.swiftindex b65b2c7e..73073bac 100644--- a/Peel/Views/Space/SpaceDetailView.swift+++ b/Peel/Views/Space/SpaceDetailView.swift@@ -68,24 +68,17 @@ struct SpaceDetailView: View {}Section {- ForEach(item.urls, id: \.self) { url in- HStack(spacing: 8) {- Image(systemName: "folder")- .foregroundStyle(.secondary)- .accessibilityHidden(true)+ ForEach(item.listedPlaces, id: \.self) { url in+ place(url) {Text(url.abbreviatedPath).lineLimit(1).truncationMode(.middle)- Spacer(minLength: 8)- Button {- NSWorkspace.shared.activateFileViewerSelecting([url])- } label: {- Label("Show in Finder", systemImage: "arrow.up.forward.app")- .minimumTarget()- }- .labelStyle(.iconOnly)- .buttonStyle(.borderless)- .help(Text("Show in Finder"))+ }+ }+ .listRowSeparator(.hidden)+ ForEach(item.inContainers, id: \.self) { folders in+ place(folders.parent) {+ Text(verbatim: Self.sentence(for: folders))}}.listRowSeparator(.hidden)@@ -121,6 +114,32 @@ struct SpaceDetailView: View {.toolbar(removing: .title)}+ private func place(_ url: URL, @ViewBuilder named name: () -> some View) -> some View {+ HStack(spacing: 8) {+ Image(systemName: "folder")+ .foregroundStyle(.secondary)+ .accessibilityHidden(true)+ name()+ Spacer(minLength: 8)+ Button {+ NSWorkspace.shared.activateFileViewerSelecting([url])+ } label: {+ Label("Show in Finder", systemImage: "arrow.up.forward.app")+ .minimumTarget()+ }+ .labelStyle(.iconOnly)+ .buttonStyle(.borderless)+ .help(Text("Show in Finder"))+ }+ }++ private static func sentence(for place: SpaceItem.ContainerFolders) -> String {+ let folders = place.folders.formatted(.list(type: .and))+ return place.areGroups+ ? String(inflecting: "\(folders) inside ^[\(place.containers) group container](inflect: true)")+ : String(inflecting: "\(folders) inside ^[\(place.containers) app container](inflect: true)")+ }+@ViewBuilderprivate func contents(of plan: SpaceRemoval.Plan) -> some View {if plan.needsFullDiskAccess || !plan.unreadable.isEmpty {