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
Leave unread a command's program whose contents live only in the cloud
Țugui Dragoșa872f86c52bf
diff --git a/Packages/PeelCore/Sources/PeelCore/Apps/IntelInspector.swift b/Packages/PeelCore/Sources/PeelCore/Apps/IntelInspector.swiftindex 3d9796ef..2363218c 100644--- a/Packages/PeelCore/Sources/PeelCore/Apps/IntelInspector.swift+++ b/Packages/PeelCore/Sources/PeelCore/Apps/IntelInspector.swift@@ -560,7 +560,13 @@ public enum IntelInspector {/// The programs the commands in `directories` run, each under the command's name. A command is often a link,/// as every one a Homebrew in `/usr/local` makes into its `Cellar`, and the program it leads to is what runs.- static func tools(in directories: [String], unreadable: inout [URL]) -> [(name: String, url: URL)] {+ /// `isDataless` stands in for a program a file provider keeps only in the cloud, which no test can make. Such a+ /// program is left unread, since reading its header would download it.+ static func tools(+ in directories: [String],+ unreadable: inout [URL],+ isDataless: (URL) -> Bool = FileSize.isDataless(_:)+ ) -> [(name: String, url: URL)] {var tools: [(name: String, url: URL)] = []for directory in directories {let folder = URL(filePath: directory, directoryHint: .isDirectory)@@ -568,7 +574,7 @@ public enum IntelInspector {let program = command.resolvingSymlinksInPath()var info = stat()if stat(program.path(percentEncoded: false), &info) == 0 {- if isRunnable(info) { tools.append((command.lastPathComponent, program)) }+ if isRunnable(info), !isDataless(program) { tools.append((command.lastPathComponent, program)) }} else if ![ENOENT, ENOTDIR, ELOOP].contains(errno),let place = FileAccess.refusedFolder(program.deletingLastPathComponent()) {unreadable.append(place)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/IntelInspectorTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/IntelInspectorTests.swiftindex f041a6ba..0758b37f 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/IntelInspectorTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/IntelInspectorTests.swift@@ -449,6 +449,23 @@ struct IntelInspectorTests {#expect(tools.map { PathPattern.comparablePath(of: $0.url) } == [PathPattern.comparablePath(of: program)])}+ @Test func leavesUnreadAProgramWhoseContentsLiveOnlyInTheCloud() throws {+ let directory = try TemporaryDirectory()+ let bin = try directory.directory("home/bin")+ for name in ["here", "inTheCloud"] {+ try directory.setPermissions(0o755, of: try directory.file("home/bin/\(name)", contents: fatHeader([intel])))+ }++ let tools = readable {+ IntelInspector.tools(+ in: [bin.path(percentEncoded: false)], unreadable: &$0,+ isDataless: { $0.lastPathComponent == "inTheCloud" }+ )+ }++ #expect(tools.map(\.name) == ["here"])+ }+@Test func findsTheIntelCommandsOfMacPortsAndOfTheHomesFoldersOfPrograms() async throws {let directory = try TemporaryDirectory()for path in ["root/usr/local/bin/brewed", "root/opt/local/bin/ported", "home/bin/legacy", "home/.local/bin/cli"] {