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
Hold back File Search's files in a repository or in Shared
Țugui Dragoș50ce16dc295d
diff --git a/GUIDE.md b/GUIDE.mdindex 866f7c40..b516387c 100644--- a/GUIDE.md+++ b/GUIDE.md@@ -153,8 +153,9 @@ Space shows what fills your disk, area by area, and what each area is.- **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.- A file in a Library folder, an app's working data, is listed last and never recommended, and one that needs an- administrator stays where it is. The page says how many files Spotlight found that it doesn't list, and why: what+ A file in a Library folder, an app's working data, is listed last and never recommended, and neither is one in a+ repository, which may be part of a project's work, or in Shared, which belongs to every account, and one that needs+ an administrator stays where it is. The page says how many files Spotlight found that it doesn't list, and why: whatsyncs to your other devices, what you excluded, what sits where Peel never moves anything, and what macOS didn't letPeel look at. A file's size is what moving it frees, the list goes by it, and a file that frees less than itslength, such as a copy that shares its storage, says so. A file you selected that a newer search no longer listsdiff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 435773d9..fd8991ce 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -102991,6 +102991,113 @@}}},+ "Not selected: it is in a repository, so it may be part of a project’s work." : {+ "comment" : "The note beside a file in File Search that sits in a Git, Mercurial, or Subversion repository.",+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nevybráno: je v repozitáři, takže může být součástí práce na projektu."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nicht ausgewählt: Diese Datei liegt in einem Repository und gehört daher möglicherweise zur Arbeit an einem Projekt."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Sin seleccionar: está en un repositorio, así que puede que forme parte del trabajo de un proyecto."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Non sélectionné : ce fichier se trouve dans un dépôt et fait donc peut-être partie du travail d’un projet."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Non selezionato: si trova in un repository, quindi potrebbe far parte del lavoro di un progetto."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未選択: リポジトリ内にあるため、プロジェクトの作業の一部である可能性があります。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "선택되지 않음: 이 파일은 저장소 안에 있으므로 프로젝트 작업의 일부일 수 있습니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Niet geselecteerd: dit staat in een repository, dus het hoort misschien bij het werk aan een project."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Nie zaznaczono: ten plik jest w repozytorium, więc może być częścią pracy nad projektem."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Não selecionado: ele está em um repositório, então pode fazer parte do trabalho de um projeto."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Neselectat: acest fișier se află într‑un depozit, așa că poate face parte din lucrările unui proiect."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Не выбрано: этот файл находится в репозитории, поэтому может быть частью работы над проектом."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Inte markerad: den ligger i ett kodförråd, så den kan vara en del av arbetet i ett projekt."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Seçilmedi: bir deponun içinde, bu yüzden bir projedeki çalışmanın parçası olabilir."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Не вибрано: цей файл міститься в репозиторії, тож він може бути частиною роботи над проєктом."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未选择:它位于代码仓库中,因此可能是某个项目工作成果的一部分。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "未選取:它位於儲存庫中,因此可能屬於某個計畫案的工作成果。"+ }+ }+ }+ },"Not selected: it is in an app’s own iCloud folder, which Finder may not show, and the app may expect to find it on this Mac." : {"comment" : "The note beside a file in iCloud Drive that sits in an app's own folder in iCloud, such as the Documents folder of an app's iCloud container, rather than in iCloud Drive itself.","localizations" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex 81c63f20..a4fa9c84 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -397,6 +397,7 @@ extension HoldBack {case .keptDownloaded: "Keep Downloaded is on for it in Finder, so iCloud downloads it again"case .inAnAppsICloudFolder: "in an app's own iCloud folder, which the app may expect to find on this Mac"case .opensOnlyOnline: "holds passwords or a wallet's keys, which would open again only online"+ case .inARepository: "in a repository, so it may be part of a project's work"case .openInAProgram: "open in a program right now, which may still be using it"case .attachedDiskImage: "a disk image open right now; eject it first"case .changedRecently: "changed in the last day, so it may still be downloading"diff --git a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swiftindex 41b8e1ab..4de0b938 100644--- a/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift+++ b/Packages/PeelCore/Sources/PeelCore/Leftovers/Leftover.swift@@ -171,6 +171,8 @@ public enum HoldBack: String, Sendable, Hashable {/// A password database or a wallet's keys in iCloud, which opens again only with an internet connection once its/// download is removed.case opensOnlyOnline+ /// A file inside a repository, which may be part of a project's work.+ case inARepository/// True when the item cannot be selected at all, rather than only left unselected: the guard or the helper/// would refuse to move it.diff --git a/Packages/PeelCore/Sources/PeelCore/Search/FileSearch.swift b/Packages/PeelCore/Sources/PeelCore/Search/FileSearch.swiftindex 111515f1..f55f578d 100644--- a/Packages/PeelCore/Sources/PeelCore/Search/FileSearch.swift+++ b/Packages/PeelCore/Sources/PeelCore/Search/FileSearch.swift@@ -57,6 +57,8 @@ public struct FoundFile: Sendable, Hashable, Identifiable {/// The file's identity when it was listed. Results can stay on screen for a long time, and a file written/// again under the same name is not the one the row describes.public var identity: FileIdentity?+ /// Why Peel doesn't recommend moving it, or nil.+ public var heldBack: HoldBack?public var id: URL { url }@@ -201,6 +203,7 @@ public enum FileSearch {if $0.belongsToAnApp != $1.belongsToAnApp { return !$0.belongsToAnApp }return $0.info.st_size != $1.info.st_size ? $0.info.st_size > $1.info.st_size : $0.path < $1.path}+ var repositories: [String: Bool] = [:]listing: for candidate in candidates {let url = URL(filePath: candidate.path)let hasRoom = results.files.count < maximumResults@@ -225,7 +228,8 @@ public enum FileSearch {modificationDate: Date(timeIntervalSince1970: TimeInterval(candidate.info.st_mtimespec.tv_sec)),requiresPrivileges: FileAccess.requiresPrivilegesToRemove(url),belongsToAnApp: candidate.belongsToAnApp,- identity: FileIdentity(candidate.info)+ identity: FileIdentity(candidate.info),+ heldBack: heldBack(url, environment: environment, repositories: &repositories)))}}@@ -239,6 +243,21 @@ public enum FileSearch {return results}+ /// Why a listed file is held back: one in /Users/Shared may be another account's, and one in a repository part+ /// of a project's work. `repositories` keeps the answer per folder, since a search lists many files of one.+ private static func heldBack(+ _ url: URL, environment: SearchEnvironment, repositories: inout [String: Bool]+ ) -> HoldBack? {+ let shared = environment.rootDirectory.appending(path: "Users/Shared").path(percentEncoded: false)+ if PathComponents.isPath(url.path(percentEncoded: false), inside: shared) { return .sharedWithEveryone }+ let folder = url.deletingLastPathComponent()+ let key = folder.path(percentEncoded: false)+ let isInARepository = repositories[key]+ ?? DuplicateFinder.isInsideARepository(folder, home: environment.homeDirectory)+ repositories[key] = isInARepository+ return isInARepository ? .inARepository : nil+ }+static func judge(_ url: URL, info: stat, kind: FileKind, refusal: (URL) -> GuardRefusal?, syncsToOtherDevices: (URL) -> Bool) -> Judgment {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/FileSearchTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/FileSearchTests.swiftindex 4fdc9046..9aecfb75 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/FileSearchTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/FileSearchTests.swift@@ -354,6 +354,30 @@ struct FileSearchTests {#expect(results.files.first?.url.lastPathComponent == "small.mov")}+ /// A file in a repository may be part of a project's work, and one in /Users/Shared another account's: both are+ /// listed and held back, never recommended.+ @Test func holdsBackWhatIsInARepositoryOrShared() throws {+ let directory = try TemporaryDirectory()+ let home = directory.url.appending(path: "home", directoryHint: .isDirectory)+ try directory.directory("home/Code/app/.git")+ let inRepository = try directory.file("home/Code/app/assets/intro.mov", bytes: 2_000)+ let shared = try directory.file("Users/Shared/trip.mov", bytes: 2_000)+ let plain = try directory.file("home/Movies/trip.mov", bytes: 2_000)++ let results = FileSearch.results(+ from: [inRepository, shared, plain].map { $0.path(percentEncoded: false) },+ environment: SearchEnvironment(homeDirectory: home, rootDirectory: directory.url),+ refusal: { _ in nil }+ )++ let held = Dictionary(uniqueKeysWithValues: results.files.map {+ ($0.url.deletingLastPathComponent().lastPathComponent, $0.heldBack)+ })+ #expect(held["assets"] == .inARepository)+ #expect(held["Shared"] == .sharedWithEveryone)+ #expect(held["Movies"] == .some(nil))+ }+@Test func asksTheGuardOnlyAboutFilesThatCanMakeTheList() throws {let directory = try TemporaryDirectory()let home = directory.url.appending(path: "home", directoryHint: .isDirectory)diff --git a/Peel/Model/FileSearchLibrary.swift b/Peel/Model/FileSearchLibrary.swiftindex 65fb87fe..24221bce 100644--- a/Peel/Model/FileSearchLibrary.swift+++ b/Peel/Model/FileSearchLibrary.swift@@ -19,7 +19,8 @@ final class FileSearchLibrary {var selectedURLs: Set<URL> = []/// The file the detail shows. The files selected for the Trash are `selectedURLs`.var chosen: URL?- /// The files Peel recommends: not the ones that need an administrator, nor the ones an app keeps for itself.+ /// The files Peel recommends: not the ones that need an administrator, the ones an app keeps for itself, nor the+ /// ones held back, in a repository or in /Users/Shared.private(set) var recommendedURLs: Set<URL> = []/// The selected files a newer search no longer lists, which stay selected until the person deselects them.private(set) var selection = SearchSelection()@@ -67,7 +68,9 @@ final class FileSearchLibrary {results = foundanswered = criteriafilteredBy = exclusions- recommendedURLs = Set(found.files.filter { !$0.requiresPrivileges && !$0.belongsToAnApp }.map(\.url))+ recommendedURLs = Set(+ found.files.filter { !$0.requiresPrivileges && !$0.belongsToAnApp && $0.heldBack == nil }.map(\.url)+ )let outsideBefore = Set(selection.outside.keys)selectedURLs = selection.update(selectedURLs, was: known, now: found.files)if Set(selection.outside.keys) != outsideBefore { keepsWhatIsOutside = false }diff --git a/Peel/Views/FileSearch/FileSearchFileView.swift b/Peel/Views/FileSearch/FileSearchFileView.swiftindex 514b786b..99f336c7 100644--- a/Peel/Views/FileSearch/FileSearchFileView.swift+++ b/Peel/Views/FileSearch/FileSearchFileView.swift@@ -44,6 +44,11 @@ struct FileSearchFileView: View {.font(.callout).foregroundStyle(.secondary)}+ if let heldBack = file.heldBack {+ Text(heldBack.explanation)+ .font(.callout)+ .foregroundStyle(.secondary)+ }if file.freesLessThanItsLength {Text("Moving this frees less than its length of \(file.length.byteCount): another file shares its storage, or it takes less space than that.").font(.callout)diff --git a/Peel/Views/FileSearch/FileSearchList.swift b/Peel/Views/FileSearch/FileSearchList.swiftindex 05e84475..f3d8143c 100644--- a/Peel/Views/FileSearch/FileSearchList.swift+++ b/Peel/Views/FileSearch/FileSearchList.swift@@ -199,6 +199,7 @@ struct FileSearchList: View {file.belongsToAnApp? String(localized: "An app keeps this in its Library folder, and may be using it right now."): nil,+ file.heldBack.map { String(localized: $0.explanation) },file.freesLessThanItsLength? String(localized: "Moving this frees less than its length of \(file.length.byteCount): another file shares its storage, or it takes less space than that."): nil,diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex 90c98963..350937b7 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -414,6 +414,8 @@ extension HoldBack {"Not selected: it is in an app’s own iCloud folder, which Finder may not show, and the app may expect to find it on this Mac."case .opensOnlyOnline:"Not selected: it holds passwords or a wallet’s keys, which open again only with an internet connection once the download is removed."+ case .inARepository:+ "Not selected: it is in a repository, so it may be part of a project’s work."case .openInAProgram:"Not selected: a program has this open right now, and may still be using it."case .attachedDiskImage: