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
Write the screenshot folder's path with no slash at the end
Țugui Dragoș591f860506cc
diff --git a/Packages/PeelCore/Sources/PeelCore/Tweaks/ScreenshotFolder.swift b/Packages/PeelCore/Sources/PeelCore/Tweaks/ScreenshotFolder.swiftindex 3d8f4451..d4f3797e 100644--- a/Packages/PeelCore/Sources/PeelCore/Tweaks/ScreenshotFolder.swift+++ b/Packages/PeelCore/Sources/PeelCore/Tweaks/ScreenshotFolder.swift@@ -9,6 +9,11 @@ public enum ScreenshotFolder {case notWritable}+ /// The path Peel writes for `folder`: one spelling, with no slash at the end, as a path written by hand.+ public static func setting(for folder: URL) -> String {+ PathPattern.comparablePath(of: folder)+ }+public static func problem(with folder: URL, home: URL = .homeDirectory) -> Problem? {var isDirectory: ObjCBool = falselet path = folder.path(percentEncoded: false)diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ScreenshotFolderTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ScreenshotFolderTests.swiftindex c4711d4e..a2222db4 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/ScreenshotFolderTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/ScreenshotFolderTests.swift@@ -27,6 +27,16 @@ struct ScreenshotFolderTests {#expect(ScreenshotFolder.problem(with: shots, home: directory.url) == .notWritable)}+ /// The setting is the folder's path as the person would write it, with no slash at the end.+ @Test func writesTheFolderWithoutATrailingSlash() throws {+ let directory = try TemporaryDirectory()+ let shots = try directory.directory("Shots")++ #expect(ScreenshotFolder.setting(for: shots) == PathPattern.comparablePath(of: shots))+ #expect(!ScreenshotFolder.setting(for: shots).hasSuffix("/"))+ #expect(ScreenshotFolder.setting(for: URL(filePath: "/Users/Shared/", directoryHint: .isDirectory)) == "/Users/Shared")+ }+@Test func refusesTheTrashAndAFolderInIt() throws {let directory = try TemporaryDirectory()let trash = try directory.directory(".Trash")diff --git a/Peel/Model/TweakLibrary.swift b/Peel/Model/TweakLibrary.swiftindex ed3610c3..5c504d3c 100644--- a/Peel/Model/TweakLibrary.swift+++ b/Peel/Model/TweakLibrary.swift@@ -119,7 +119,7 @@ final class TweakLibrary {// Asked again once the panel has closed, since the folder can change after the panel's own check.guard let url = await ScreenshotFolderPanel.choose(), ScreenshotFolder.problem(with: url) == nilelse { return }- await turnOn(tweak, text: url.path(percentEncoded: false))+ await turnOn(tweak, text: ScreenshotFolder.setting(for: url))}/// The settings Peel could not write, so each row can say so instead of letting the switch spring back