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
Say when Git's list of tracked files took too long to read
Țugui Dragoș265e86a82dab
diff --git a/AGENTS.md b/AGENTS.mdindex aa919371..ce9f80ad 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -125,7 +125,8 @@ checked by hand. If a change makes one of them fail, the rule is right and the cname a program for Git to run (`core.fsmonitor`), so whether a build folder holds files Git tracks is read fromthe index itself, as `gitformat-index(5)` describes it (`GitIndex`), never asked of Git. A folder that holdstracked files, such as `Pods` kept in the repository as CocoaPods suggests, is listed with that reason and never- recommended, and so is one in a repository whose index can't be read.+ recommended, and so is one in a repository whose index can't be read, or can't be read in time, each with its own+ reason.- **Resetting an app clears its settings, never the app.** It takes the app's own data only when the user selectsit, needs the app to be quit, and inside a sandboxed app's container never touches `Documents`,`Application Support`, or `Autosave Information`.diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex a05ceaec..208cafbb 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -103303,6 +103303,113 @@}}},+ "Not selected: reading which files Git tracks here took too long, so this folder may be part of the project. Rescan to try again." : {+ "comment" : "The note beside a row in Build Artifacts. Peel reads Git's own list of the files it tracks, and that read ran out of time. Rescan is the toolbar button that scans the page again.",+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nevybráno: čtení seznamu souborů, které tu Git sleduje, trvalo příliš dlouho, takže tato složka může být součástí projektu. Chcete-li to zkusit ještě jednou, klikněte na Prohledat znovu."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nicht ausgewählt: Das Lesen der Liste der hier von Git versionierten Dateien hat zu lange gedauert, daher gehört dieser Ordner möglicherweise zum Projekt. Klicke auf „Erneut scannen“, um es noch einmal zu versuchen."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Sin seleccionar: Peel ha tardado demasiado en leer qué archivos rastrea Git aquí, así que puede que esta carpeta forme parte del proyecto. Usa “Volver a analizar” para intentarlo otra vez."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Non sélectionné : la lecture de la liste des fichiers que Git suit ici a pris trop de temps, et ce dossier peut donc faire partie du projet. Analysez à nouveau pour réessayer."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Non selezionato: leggere l’elenco dei file tracciati da Git qui ha richiesto troppo tempo, quindi questa cartella potrebbe far parte del progetto. Per riprovare, fai clic su “Analizza di nuovo”."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未選択: ここでGitが追跡しているファイルのリストを読み取るのに時間がかかりすぎたため、このフォルダはプロジェクトの一部である可能性があります。やり直すには、再スキャンしてください。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "선택되지 않음: 여기에서 Git이 추적하는 파일을 읽는 데 시간이 너무 오래 걸렸으므로 이 폴더는 프로젝트의 일부일 수 있습니다. 다시 시도하려면 다시 스캔하십시오."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Niet geselecteerd: het lezen van de lijst met bestanden die Git hier volgt, duurde te lang, dus deze map hoort misschien bij het project. Klik op 'Scan opnieuw' om het nog eens te proberen."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nie zaznaczono: odczytywanie listy plików śledzonych tu przez Git trwało zbyt długo, więc ten folder może być częścią projektu. Kliknij w przycisk Skanuj ponownie, aby spróbować jeszcze raz."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Não selecionado: a leitura da lista de arquivos que o Git rastreia aqui demorou demais, então esta pasta pode fazer parte do projeto. Clique em Analisar Novamente para tentar de novo."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Neselectat: citirea listei de fișiere pe care Git le urmărește aici a durat prea mult, așa că acest dosar ar putea face parte din proiect. Rescanați pentru a încerca din nou."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Не выбрано: чтение списка файлов, которые здесь отслеживает Git, заняло слишком много времени, поэтому эта папка может быть частью проекта. Чтобы повторить попытку, нажмите «Сканировать заново»."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Inte markerad: det tog för lång tid att läsa vilka filer Git spårar här, så den här mappen kan vara en del av projektet. Skanna igen för att försöka på nytt."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Seçilmedi: Git’in burada hangi dosyaları izlediğini okumak çok uzun sürdü, bu yüzden bu klasör projenin bir parçası olabilir. Yeniden denemek için Yeniden Tara’yı tıklayın."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Не вибрано: читання списку файлів, які тут відстежує Git, тривало надто довго, тож ця папка може бути частиною проєкту. Натисніть «Сканувати знову», щоб спробувати ще раз."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未选择:读取Git在此处跟踪的文件列表耗时过长,因此此文件夹可能是项目的一部分。可通过“重新扫描”再试一次。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未選取:讀取Git在此處追蹤了哪些檔案耗時過久,因此此檔案夾可能是計畫案的一部分。請按一下「重新掃描」再試一次。"+ }+ }+ }+ },"Not selected: something in this project changed in the last 7 days." : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex 61857e14..3b3215cb 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -353,6 +353,7 @@ extension HoldBack {case .holdsRepository: "holds a repository"case .trackedByGit: "Git tracks files in it"case .gitTrackingNotKnown: "in a Git repository whose tracked files couldn't be read"+ case .gitTrackingNotReadInTime: "reading which files Git tracks here took too long"case .keepsItsSetup: "keeps the options its build was set up with"case .sharedWithEveryone: "belongs to everyone on this Mac"case .holdsWhatOthersPut: "holds files something besides this package put there"diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swiftindex d15a469a..36ef2de3 100644--- a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift+++ b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift@@ -932,18 +932,23 @@ public enum ProjectArtifacts {/// Holds back each artifact Git tracks files in, which is part of the project rather than something a build makes/// again, and each in a repository whose index can't be read. What the walk saw inside comes first.- static func holdingBackWhatGitTracks(_ artifacts: [ProjectArtifact]) async -> [ProjectArtifact] {+ static func holdingBackWhatGitTracks(+ _ artifacts: [ProjectArtifact],+ within budget: TimeInterval = FileSize.budget,+ readingIndex readIndex: @escaping @Sendable (GitIndex.Repository) -> GitIndex? = GitIndex.read+ ) async -> [ProjectArtifact] {var result = artifactsvar indexes: [GitIndex.Repository: GitIndex?] = [:]+ var outOfTime: Set<GitIndex.Repository> = []let projects = Dictionary(grouping: result.indices.filter { result[$0].heldBack == nil }) { result[$0].project }for (project, positions) in projects {guard !Task.isCancelled else { break }func hold(_ reason: HoldBack, _ held: [Int]) {for position in held { result[position].heldBack = reason }}- let found = await SlowRead.answer(within: FileSize.budget) { _ in GitIndex.repository(containing: project) }+ let found = await SlowRead.answer(within: budget) { _ in GitIndex.repository(containing: project) }guard let found else {- hold(.gitTrackingNotKnown, positions)+ hold(.gitTrackingNotReadInTime, positions)continue}guard let repository = found else { continue }@@ -951,19 +956,21 @@ public enum ProjectArtifacts {if let read = indexes[repository] {index = read} else {- index = await SlowRead.answer(within: FileSize.budget) { _ in GitIndex.read(repository) } ?? nil+ let read = await SlowRead.answer(within: budget) { _ in readIndex(repository) }+ if read == nil { outOfTime.insert(repository) }+ index = read ?? nilindexes.updateValue(index, forKey: repository)}guard let index else {- hold(.gitTrackingNotKnown, positions)+ hold(outOfTime.contains(repository) ? .gitTrackingNotReadInTime : .gitTrackingNotKnown, positions)continue}let folders = positions.map { result[$0].url }- let tracked = await SlowRead.answer(within: FileSize.budget) { _ in+ let tracked = await SlowRead.answer(within: budget) { _ infolders.map { index.tracksSomething(atOrInside: $0, of: repository) }}guard let tracked else {- hold(.gitTrackingNotKnown, positions)+ hold(.gitTrackingNotReadInTime, positions)continue}hold(.trackedByGit, zip(positions, tracked).filter(\.1).map(\.0))diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swiftindex e874a3a2..6a4b7abc 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift@@ -50,6 +50,8 @@ public enum HoldBack: String, Sendable, Hashable {case trackedByGit/// Inside a Git repository whose index could not be read, so whether Git tracks files inside is not known.case gitTrackingNotKnown+ /// Reading which files Git tracks there took longer than its budget, so that is not known until a later scan.+ case gitTrackingNotReadInTime/// A build folder that also keeps the options its build was set up with, which nothing else in the project holds.case keepsItsSetup/// `/Users/Shared`, which belongs to every account on the Mac rather than to one app.diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swiftindex 3bc61cc3..b46e5669 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift@@ -1228,6 +1228,31 @@ struct ProjectArtifactsTests {#expect(!pods.isRecommended)}+ /// An index that takes longer than its budget to read says so, rather than that it couldn't be read.+ @Test func whatGitTracksIsNotKnownYetWhileItsIndexTakesTooLong() async throws {+ let directory = try TemporaryDirectory()+ let git = try await GitFixture(home: directory.url.appending(path: "home"))+ try directory.file("Code/App/Podfile")+ try directory.file("Code/App/Pods/Foo/Foo.m")+ let project = directory.url.appending(path: "Code/App", directoryHint: .isDirectory)+ try await git.run("init", "-q", in: project)+ try await git.run("add", "Podfile", in: project)+ try age(directory.url, days: 60)+ let found = await ProjectArtifacts.scan(roots: [directory.url.appending(path: "Code")]).artifacts+ let pods = try #require(found.first)+ #expect(pods.heldBack == nil)+ let unanswered = DispatchSemaphore(value: 0)+ defer { unanswered.signal() }++ let held = await ProjectArtifacts.holdingBackWhatGitTracks([pods], within: 0.05) { _ in+ unanswered.wait()+ return nil+ }++ #expect(held.first?.heldBack == .gitTrackingNotReadInTime)+ #expect(held.first?.isRecommended == false)+ }+/// A large `node_modules` is the folder most likely to run out of time. Its size is then unknown, not zero,/// so it is listed first and never selected for the user.@Test func anArtifactThatDidNotAnswerInTimeIsNotReadAsEmpty() async throws {diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex d72d040d..cf9e6d04 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -332,6 +332,8 @@ extension HoldBack {"Not selected: Git tracks files in this folder, so it is part of the project. Moving it would show them as deleted in Git."case .gitTrackingNotKnown:"Not selected: this folder is in a Git repository whose list of tracked files Peel couldn’t read, so it may be part of the project."+ case .gitTrackingNotReadInTime:+ "Not selected: reading which files Git tracks here took too long, so this folder may be part of the project. Rescan to try again."case .keepsItsSetup:"Not selected: it also keeps the options this build was set up with, which nothing else in the project holds."case .sharedWithEveryone:diff --git a/SAFETY.md b/SAFETY.mdindex 0bd2326a..6f0aced3 100644--- a/SAFETY.md+++ b/SAFETY.md@@ -436,7 +436,8 @@ Build Artifacts recommends what a build or a package manager makes again from thincludes `node_modules` and `Pods`, which `npm install` and `pod install` put back from the project's `package.json` and`Podfile`, unless Git tracks files in them: CocoaPods suggests keeping `Pods` in the repository, and a folder Git tracksis part of the project, so it is listed and never selected, and so is one in a repository whose list of tracked files-Peel can't read. Peel reads that list from Git's own index, as Git documents it, and never runs Git in a project.+Peel can't read, or can't read in time. Peel reads that list from Git's own index, as Git documents it, and never runs+Git in a project.Installed packages are listed and never selected, since packages are often installed into them by hand: a Pythonenvironment (`.venv`, `venv`, `env`, PDM's `__pypackages__`, tox's `.tox`, Nox's `.nox`, and any folder that holds the`pyvenv.cfg` every environment has, beside a Python project's own file or tagged as a cache), Composer's `vendor`, Mix's