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
Build Artifacts knows any folder its tool tagged as a cache
Țugui Dragoș880cfb3afe56
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex a6bb7fb6..937bc16f 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -54788,6 +54788,112 @@}}},+ "Marked as a cache by the tool that made it" : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Označeno jako mezipaměť nástrojem, který ji vytvořil"+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Vom erstellenden Tool als Cache gekennzeichnet"+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Marcada como caché por la herramienta que la generó"+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Marqué comme cache par l’outil qui l’a créé"+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Contrassegnato come cache dallo strumento che l’ha creato"+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "作成したツールがキャッシュとして指定"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "만든 도구가 캐시로 표시함"+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Als cache gemarkeerd door de tool die de map aanmaakte"+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Oznaczony jako pamięć podręczna przez narzędzie, które go utworzyło"+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Marcado como cache pela ferramenta que o gerou"+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Marcat ca memorie tampon de instrumentul care l‑a creat"+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Помечено как кэш создавшим его инструментом"+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Märkt som cache av verktyget som skapade den"+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Oluşturan araç tarafından önbellek olarak işaretlendi"+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Позначено як кеш інструментом, який її створив"+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "由生成它的工具标记为缓存"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "由產生它的工具標示為快取"+ }+ }+ }+ },"Media and Backups" : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swiftindex d30a12de..6583bc3c 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Commands/FileCommands.swift@@ -305,7 +305,7 @@ struct ProjectsCommand: AsyncParsableCommand {static let configuration = CommandConfiguration(commandName: "projects",abstract: "List what builds left behind in your projects, and move it to the Trash.",- discussion: "A folder only counts when the file that makes it sits beside it. Projects changed in the last 7 days, and folders under a name that could mean anything, are listed but never suggested, and --remove moves only what is suggested."+ discussion: "A folder only counts when the file that makes it sits beside it, or its tool tagged it as a cache. Projects changed in the last 7 days, and folders under a name that could mean anything, are listed but never suggested, and --remove moves only what is suggested.")@Argument(help: "Folders your projects live in.", completion: .directory)@@ -321,7 +321,8 @@ struct ProjectsCommand: AsyncParsableCommand {struct Record: Encodable {let path: Stringlet project: String- let tool: String+ /// `null` for a folder known only by the cache directory tag its tool wrote.+ let tool: String?let size: MeasuredSizelet suggested: Boollet recentlyActive: Bool@@ -454,7 +455,7 @@ struct ProjectsCommand: AsyncParsableCommand {}static func rows(for artifacts: [ProjectArtifact]) -> [[String]] {- artifacts.map { [Output.size($0.size), Output.path($0.url), $0.tool, note(for: $0)] }+ artifacts.map { [Output.size($0.size), Output.path($0.url), $0.tool ?? "tagged as a cache", note(for: $0)] }}/// Returns why `artifact` is kept, or "suggested". It checks the same conditions as `isRecommended`, anddiff --git a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swiftindex b25faf6e..76e41df9 100644--- a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift+++ b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift@@ -7,7 +7,8 @@ public struct ProjectArtifact: Sendable, Hashable, Identifiable {public let url: URLpublic let project: URLpublic let name: String- public let tool: String+ /// Nil for a folder known only by the cache directory tag its tool wrote, which does not say which tool it was.+ public let tool: String?/// Nil when it was not measured, which is not the same as empty.public let size: Int64?/// The latest change in the project's own files, its artifacts left out.@@ -485,20 +486,27 @@ public enum ProjectArtifacts {let names = Set(entries.map(\.lastPathComponent))var artifactNames: Set<String> = []- var matching: [(definition: Definition, name: String)] = []+ var matching: [(name: String, definition: Definition?)] = []for definition in definitions {for name in definition.candidates(among: names) {let url = folder.appending(path: name)guard isRealFolder(url), definition.matches(url, in: folder, besides: names) else { continue }guard !exclusions.excludes(url), !exclusions.holds(url) else { continue }guard artifactNames.insert(name).inserted else { continue }- matching.append((definition, name))+ matching.append((name, definition))reached.insert(Self.key(of: url))}}+ for entry in entries where !artifactNames.contains(entry.lastPathComponent) {+ guard isRealFolder(entry), isTaggedAsACache(entry) else { continue }+ guard !exclusions.excludes(entry), !exclusions.holds(entry) else { continue }+ artifactNames.insert(entry.lastPathComponent)+ matching.append((entry.lastPathComponent, nil))+ reached.insert(Self.key(of: entry))+ }// Read after all of the project's artifacts are found, so the walk skips every one of them.let activity = matching.isEmpty ? (date: nil, isCertain: true) : lastActivity(in: folder, ignoring: artifactNames)- for (definition, name) in matching {+ for (name, definition) in matching {let url = folder.appending(path: name)let contents = await measure(url)let heldBack = HoldBack.seen(in: contents)@@ -506,12 +514,12 @@ public enum ProjectArtifacts {url: url,project: folder,name: name,- tool: definition.tool,+ tool: definition?.tool,size: contents.flatMap { $0.couldNotBeRead ? nil : $0.size },lastActivity: activity.date,lastActivityIsCertain: activity.isCertain,- hasGenericName: definition.isGeneric,- isEnvironment: definition.isEnvironment,+ hasGenericName: definition?.isGeneric ?? false,+ isEnvironment: definition?.isEnvironment ?? false,// A tool that tags its folder as a cache makes everything in it again, its own clones included.heldBack: heldBack == .holdsRepository && isTaggedAsACache(url) ? nil : heldBack))@@ -610,7 +618,7 @@ extension ProjectArtifact {public func matches(_ query: String) -> Bool {guard !query.isEmpty else { return true }return SearchText.matches(name, query)- || SearchText.matches(tool, query)+ || (tool.map { SearchText.matches($0, query) } ?? false)|| SearchText.matches(project.lastPathComponent, query)}}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swiftindex 4295b208..763a7669 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift@@ -209,6 +209,28 @@ struct ProjectArtifactsTests {#expect(found.first?.isRecommended == true, "the cache's own new files counted as work in the project")}+ @Test func findsAFolderItsToolTaggedAsACacheWhateverItIsCalled() async throws {+ let directory = try TemporaryDirectory()+ let tag = Data("Signature: 8a477f597d28d172789f06886806bc55\n# This file is a cache directory tag.\n".utf8)+ try directory.file("app/main.c", bytes: 16)+ try directory.file("app/scratch-cache/CACHEDIR.TAG", contents: tag)+ try directory.file("app/scratch-cache/objects/blob", bytes: 400_000)+ try directory.file("app/look-alike/CACHEDIR.TAG", contents: Data("not a tag".utf8))+ try directory.file("app/look-alike/notes.txt", bytes: 400_000)+ try directory.file("crate/Cargo.toml", bytes: 16)+ try directory.file("crate/target/CACHEDIR.TAG", contents: tag)+ try directory.file("crate/target/debug/crate", bytes: 400_000)+ try age(directory.url, days: 60)++ let found = await ProjectArtifacts.scan(roots: [directory.url]).artifacts++ #expect(Set(found.map { "\($0.project.lastPathComponent)/\($0.name)" }) == ["app/scratch-cache", "crate/target"])+ let tagged = try #require(found.first { $0.name == "scratch-cache" })+ #expect(tagged.tool == nil)+ #expect(tagged.isRecommended)+ #expect(found.first { $0.name == "target" }?.tool == "Cargo")+ }+@Test func aUnityProjectsObjIsUnitysThoughDotNetsProjectFileSitsBesideIt() async throws {let directory = try TemporaryDirectory()try directory.file("game/ProjectSettings/ProjectVersion.txt", bytes: 16)diff --git a/Peel/Views/Projects/ProjectDetailView.swift b/Peel/Views/Projects/ProjectDetailView.swiftindex 33cd4d9b..8ba2326d 100644--- a/Peel/Views/Projects/ProjectDetailView.swift+++ b/Peel/Views/Projects/ProjectDetailView.swift@@ -102,7 +102,8 @@ struct ProjectDetailView: View {}private func detail(for artifact: ProjectArtifact) -> LocalizedStringResource {- "Made by \(artifact.tool)"+ guard let tool = artifact.tool else { return "Marked as a cache by the tool that made it" }+ return "Made by \(tool)"}private func warning(for artifact: ProjectArtifact) -> String? {diff --git a/Support/peel.1 b/Support/peel.1index 493cb4dc..d528d74a 100644--- a/Support/peel.1+++ b/Support/peel.1@@ -213,7 +213,7 @@ Show help information..It Em projectsList what builds left behind in your projects, and move it to the Trash..Pp-A folder only counts when the file that makes it sits beside it. Projects changed in the last 7 days, and folders under a name that could mean anything, are listed but never suggested, and --remove moves only what is suggested.+A folder only counts when the file that makes it sits beside it, or its tool tagged it as a cache. Projects changed in the last 7 days, and folders under a name that could mean anything, are listed but never suggested, and --remove moves only what is suggested..Bl -tag -width 6n.It Ar folders...Folders your projects live in.