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
Know a shared home item that sits inside a hidden folder
Țugui Dragoș68020ae90b8c
diff --git a/Packages/PeelCore/Sources/PeelPrivileged/ProtectedData.swift b/Packages/PeelCore/Sources/PeelPrivileged/ProtectedData.swiftindex 0a05ba54..1eab9922 100644--- a/Packages/PeelCore/Sources/PeelPrivileged/ProtectedData.swift+++ b/Packages/PeelCore/Sources/PeelPrivileged/ProtectedData.swift@@ -325,7 +325,7 @@ public enum ProtectedData: Sendable {return folder.hasSuffix("/library/preferences") || folder.hasSuffix("/library/preferences/byhost")}- private static let sharedHomeItemNames = Set(sharedHomeItems.map { $0.lowercased() })+ private static let sharedHomeItemNames = Set(sharedHomeItems.map { PathComponents.of($0.lowercased()) })/// True for one of `sharedHomeItems` exactly, never for anything inside one.public static func isSharedHomeItem(_ path: String, home: String) -> Bool {@@ -333,10 +333,8 @@ public enum ProtectedData: Sendable {let homeNames = PathComponents.of(home)return spellings(of: path).contains { spelling inlet names = PathComponents.of(spelling)- guard names.count == homeNames.count + 1, names.starts(with: homeNames), let name = names.last else {- return false- }- return sharedHomeItemNames.contains(name)+ guard names.count > homeNames.count, names.starts(with: homeNames) else { return false }+ return sharedHomeItemNames.contains(Array(names.dropFirst(homeNames.count)))}}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swiftindex 1f9c91e6..3f58d984 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/LeftoverScannerTests.swift@@ -929,6 +929,15 @@ struct LeftoverScannerTests {#expect(paths == ["home/.local/share/local", "home/.config/local"])}+ @Test func aSharedHomeItemCanSitInsideAHiddenFolder() {+ let home = "/Users/example"+ #expect(ProtectedData.isSharedHomeItem("/Users/example/.kube/config", home: home))+ #expect(ProtectedData.isSharedHomeItem("/Users/example/.kube", home: home))+ #expect(!ProtectedData.isSharedHomeItem("/Users/example/.kube/cache", home: home))+ #expect(!ProtectedData.isSharedHomeItem("/Users/example/.kube/config/backup", home: home))+ #expect(!ProtectedData.isSharedHomeItem("/Users/example/.config/op", home: home))+ }+/// A folder with a repository inside holds more than the app's own state. It is still listed as the app's,/// but not selected, because work that is not committed or not pushed exists nowhere else.