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 macOS didn't allow a Put Back into a folder it keeps Peel out of
Țugui Dragoș673fe01ca9cd
diff --git a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swiftindex 91540e10..bc129834 100644--- a/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift+++ b/Packages/PeelCore/Sources/PeelCore/Removal/TrashService.swift@@ -791,7 +791,9 @@ public struct TrashService: Sendable {guard item.isInTheTrash else { return .missingFromTrash }guard !item.originalURL.isThere else { return .alreadyThere }if FileAccess.isLockedInFinder(item.trashedURL) { return .locked }- if FileAccess.isLockedInFinder(URL(filePath: Self.folder(puttingBack: item))) { return .folderLocked }+ let folder = URL(filePath: Self.folder(puttingBack: item))+ let privacy = FileAccess.isProtectedByPrivacy(folder)+ if let refusal = Self.refusal(ofPuttingBackInto: folder, isProtectedByPrivacy: privacy) { return refusal }if Self.needsTheHelper(toPutBack: item) {if Self.isFolderGone(puttingBack: item) { return .folderGone }let reach = HelperReach(environment: environment)@@ -803,6 +805,13 @@ public struct TrashService: Sendable {return nil}+ /// What keeps an item out of `folder` whoever puts it back, the helper included: Finder's lock, or macOS's+ /// privacy protection. Only the permissions are the helper's to pass.+ static func refusal(ofPuttingBackInto folder: URL, isProtectedByPrivacy: Bool) -> RestoreFailure? {+ if FileAccess.isLockedInFinder(folder) { return .folderLocked }+ return isProtectedByPrivacy ? .notPermitted : nil+ }+/// The nearest folder on `item`'s way back that exists, as the kernel names it, which its Put Back writes into:/// missing folders are made again.static func folder(puttingBack item: TrashedItem) -> String {diff --git a/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swiftindex 08ff5ed7..e9313918 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/TrashServiceTests.swift@@ -643,6 +643,14 @@ struct TrashServiceTests {#expect(lockedFolder == .folderLocked)}+ @Test func aWayBackMacOSsPrivacyProtectionClosesIsNoHelpersToOpen() throws {+ let directory = try TemporaryDirectory()+ let downloads = try directory.directory("home/Downloads")++ #expect(TrashService.refusal(ofPuttingBackInto: downloads, isProtectedByPrivacy: true) == .notPermitted)+ #expect(TrashService.refusal(ofPuttingBackInto: downloads, isProtectedByPrivacy: false) == nil)+ }+@Test func aFolderLockedBehindALinkOnTheWayBackIsSaidSo() async throws {let directory = try TemporaryDirectory()let documents = try directory.directory("home/Documents")