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
Name a disk Spotlight doesn't index whatever a search of This Mac finds
Țugui Dragoș788e34d27a0e
diff --git a/GUIDE.md b/GUIDE.mdindex fe1311a3..628e4e2b 100644--- a/GUIDE.md+++ b/GUIDE.md@@ -160,7 +160,7 @@ Space shows what fills your disk, area by area, and what each area is.- **Space:** what fills your disk, area by area, and which app or tool each area belongs to.- **File Search:** files by name, kind, or size, and by age along with one of them, in your home folder or across thisMac's disks, not network volumes, found through Spotlight, up to 2,000 at a time, so a folder in System Settings >- Spotlight > Search Privacy isn't searched; when nothing is found, the page names any disk Spotlight isn't indexing.+ Spotlight > Search Privacy isn't searched, and the page names any disk Spotlight isn't indexing.A file in a Library folder, an app's working data, is listed last and never recommended, and neither is one in arepository, which may be part of a project's work, or in Shared, which belongs to every account, and one that needsan administrator stays where it is. The page says how many files Spotlight found that it doesn't list, and why: whatdiff --git a/Packages/PeelCore/Sources/PeelCore/Search/FileSearch.swift b/Packages/PeelCore/Sources/PeelCore/Search/FileSearch.swiftindex 3cd7dd55..f05472b0 100644--- a/Packages/PeelCore/Sources/PeelCore/Search/FileSearch.swift+++ b/Packages/PeelCore/Sources/PeelCore/Search/FileSearch.swift@@ -77,9 +77,9 @@ public struct FileSearchResults: Sendable {public var syncedBy: [SyncKeeper] = []/// False when the query itself could not be made or run, which is not the same as finding nothing.public var didRun = true- /// The disks Spotlight doesn't index, named as Finder names them, asked only when nothing was found.+ /// The disks Spotlight doesn't index, named as Finder names them.public var unindexedDisks: [String] = []- /// True when Spotlight indexes none of the disks searched.+ /// True when nothing was found and Spotlight indexes none of the disks searched.public var isNothingIndexed = false}@@ -160,14 +160,16 @@ public enum FileSearch {MDQuerySetSearchScope(query, [scope] as CFArray, 0)guard let paths = await gather(query), !Task.isCancelled else { return FileSearchResults(didRun: false) }var results = results(from: paths, kind: criteria.kind, environment: environment, exclusions: exclusions)- guard results.didRun, results.files.isEmpty else { return results }+ // Files found on one disk say nothing of another, while a search of the home that found any has read its disk.+ guard results.didRun, results.files.isEmpty || criteria.scope == .computer else { return results }let searched = disks(criteria.scope)?? SpotlightIndex.disks(in: criteria.scope, home: environment.homeDirectory)for disk in searched where await isIndexing(disk.volume) == false {results.unindexedDisks.append(disk.name)}guard !Task.isCancelled else { return FileSearchResults(didRun: false) }- results.isNothingIndexed = !searched.isEmpty && results.unindexedDisks.count == searched.count+ results.isNothingIndexed = results.files.isEmpty && !searched.isEmpty+ && results.unindexedDisks.count == searched.countreturn results}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileSearchTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileSearchTests.swiftindex c02c46c5..e3738f16 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/FileSearchTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileSearchTests.swift@@ -80,6 +80,30 @@ struct FileSearchTests {#expect(found.files.count == 1 && found.unindexedDisks.isEmpty)}+ @Test func aSearchOfThisMacNamesTheDisksSpotlightDoesNotIndexWhateverItFinds() async throws {+ let directory = try TemporaryDirectory()+ let file = try directory.file("report.txt")+ var criteria = FileSearchCriteria()+ criteria.name = "report"+ criteria.scope = .computer+ let disks = [+ SpotlightIndex.Disk(volume: URL(filePath: "/System/Volumes/Data"), name: "Macintosh HD"),+ SpotlightIndex.Disk(volume: URL(filePath: "/Volumes/Backup"), name: "Backup"),+ ]+ func search(indexing: Set<String>) async -> FileSearchResults {+ await FileSearch.run(+ criteria, gather: { _ in [file.path(percentEncoded: false)] }, disks: { _ in disks },+ isIndexing: { indexing.contains($0.path) }+ )+ }++ let some = await search(indexing: ["/System/Volumes/Data"])+ let none = await search(indexing: [])++ #expect(some.files.count == 1 && some.unindexedDisks == ["Backup"] && !some.isNothingIndexed)+ #expect(none.files.count == 1 && none.unindexedDisks.count == 2 && !none.isNothingIndexed)+ }+@Test func buildsQueryFromCriteria() {var criteria = FileSearchCriteria()criteria.name = " Budget "diff --git a/Peel/Views/FileSearch/FileSearchList.swift b/Peel/Views/FileSearch/FileSearchList.swiftindex 6a4bfc76..e250910e 100644--- a/Peel/Views/FileSearch/FileSearchList.swift+++ b/Peel/Views/FileSearch/FileSearchList.swift@@ -41,6 +41,14 @@ struct FileSearchList: View {.foregroundStyle(.secondary).listRowSeparator(.hidden)}+ if let results = search.results, !results.files.isEmpty, !results.unindexedDisks.isEmpty {+ Label(+ "Spotlight isn’t indexing \(results.unindexedDisks.formatted(.list(type: .and))), so File Search can’t find anything there.",+ systemImage: "magnifyingglass"+ )+ .foregroundStyle(.secondary)+ .listRowSeparator(.hidden)+ }if let results = search.results, !results.files.isEmpty {Section {ForEach(results.files) { file in