Skip to content

armgit / peel

Public Imported from GitHub
0

Uninstall Mac apps with every file they leave behind, and see why each belongs. Free up space, fine-tune macOS, and set up Terminal.

Name the first four folders Peel couldn't read, and copy the rest

Țugui Dragoș4d3596b2400f
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index 13d46c96..ced7da78 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -206448,6 +206448,346 @@
}
}
},
+ "^[%lld more folder](inflect: true)" : {
+ "localizations" : {
+ "cs" : {
+ "variations" : {
+ "plural" : {
+ "few" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld další složky"
+ }
+ },
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld další složky"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld další složka"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld dalších složek"
+ }
+ }
+ }
+ }
+ },
+ "de" : {
+ "variations" : {
+ "plural" : {
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "noch %lld Ordner"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "noch %lld Ordner"
+ }
+ }
+ }
+ }
+ },
+ "es" : {
+ "variations" : {
+ "plural" : {
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld de carpetas más"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld carpeta más"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld carpetas más"
+ }
+ }
+ }
+ }
+ },
+ "fr" : {
+ "variations" : {
+ "plural" : {
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld d’autres dossiers"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld autre dossier"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld autres dossiers"
+ }
+ }
+ }
+ }
+ },
+ "it" : {
+ "variations" : {
+ "plural" : {
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "altre %lld di cartelle"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "un’altra cartella"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "altre %lld cartelle"
+ }
+ }
+ }
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "その他%lld個のフォルダ"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "그 외 폴더 %lld개"
+ }
+ },
+ "nl" : {
+ "variations" : {
+ "plural" : {
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld andere map"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld andere mappen"
+ }
+ }
+ }
+ }
+ },
+ "pl" : {
+ "variations" : {
+ "plural" : {
+ "few" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "jeszcze %lld foldery"
+ }
+ },
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "jeszcze %lld folderów"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "jeszcze %lld folder"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "jeszcze %lld folderu"
+ }
+ }
+ }
+ }
+ },
+ "pt" : {
+ "variations" : {
+ "plural" : {
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "mais %lld de pastas"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "mais %lld pasta"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "mais %lld pastas"
+ }
+ }
+ }
+ }
+ },
+ "ro" : {
+ "variations" : {
+ "plural" : {
+ "few" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "încă %lld dosare"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "încă %lld dosar"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "încă %lld de dosare"
+ }
+ }
+ }
+ }
+ },
+ "ru" : {
+ "variations" : {
+ "plural" : {
+ "few" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "еще %lld папки"
+ }
+ },
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "еще %lld папок"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "еще %lld папка"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "еще %lld папки"
+ }
+ }
+ }
+ }
+ },
+ "sv" : {
+ "variations" : {
+ "plural" : {
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld mapp till"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld mappar till"
+ }
+ }
+ }
+ }
+ },
+ "tr" : {
+ "variations" : {
+ "plural" : {
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld klasör daha"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "%lld klasör daha"
+ }
+ }
+ }
+ }
+ },
+ "uk" : {
+ "variations" : {
+ "plural" : {
+ "few" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "ще %lld папки"
+ }
+ },
+ "many" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "ще %lld папок"
+ }
+ },
+ "one" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "ще %lld папка"
+ }
+ },
+ "other" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "ще %lld папки"
+ }
+ }
+ }
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "其他%lld个文件夹"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "其他%lld個檔案夾"
+ }
+ }
+ }
+ },
"^[%lld more line](inflect: true)" : {
"localizations" : {
"cs" : {
diff --git a/Peel/Views/Duplicates/DuplicateList.swift b/Peel/Views/Duplicates/DuplicateList.swift
index 025a98a9..925e915e 100644
--- a/Peel/Views/Duplicates/DuplicateList.swift
+++ b/Peel/Views/Duplicates/DuplicateList.swift
@@ -68,7 +68,7 @@ struct DuplicateList: View {
if scan.needsFullDiskAccess {
Text("No duplicates were found, but macOS kept Peel out of a folder you chose. Give Peel Full Disk Access to look there too.")
} else if !scan.unreadableLocations.isEmpty {
- Text("Peel couldn’t look inside \(scan.unreadableLocations.map(\.abbreviatedPath).formatted(.list(type: .and))), so something may be there that isn’t listed here.")
+ Text("Peel couldn’t look inside \(RemovalFailureAlert.listedFolders(scan.unreadableLocations.map(\.abbreviatedPath))), so something may be there that isn’t listed here.")
}
if !scan.skippedLocations.isEmpty {
Text(verbatim: Self.reasons(scan.skippedLocations))
@@ -76,6 +76,11 @@ struct DuplicateList: View {
} actions: {
if scan.needsFullDiskAccess {
Button("Open System Settings") { home.openFullDiskAccessSettings() }
+ } else if scan.unreadableLocations.count > RemovalFailureAlert.mostListed {
+ CopyButton(
+ text: scan.unreadableLocations.map(\.abbreviatedPath).joined(separator: "\n"),
+ title: "Copy Details"
+ )
}
}
} else if scan.groups.isEmpty, scan.folderGroups.isEmpty {
diff --git a/Peel/Views/RemovalFailureAlert.swift b/Peel/Views/RemovalFailureAlert.swift
index 2f5fdb2b..eba82a68 100644
--- a/Peel/Views/RemovalFailureAlert.swift
+++ b/Peel/Views/RemovalFailureAlert.swift
@@ -28,6 +28,11 @@ struct RemovalFailureAlert: ViewModifier {
listed(names) { String(inflecting: "^[\($0) more app](inflect: true)") }
}
+ /// Folders named in one sentence, the same way.
+ static func listedFolders(_ paths: [String]) -> String {
+ listed(paths) { String(inflecting: "^[\($0) more folder](inflect: true)") }
+ }
+
private static func listed(_ names: [String], others: (Int) -> String) -> String {
guard names.count > mostListed else { return names.formatted(.list(type: .and)) }
return (names.prefix(mostListed) + [others(names.count - mostListed)]).formatted(.list(type: .and))
diff --git a/Peel/Views/UnreadableFoldersNotice.swift b/Peel/Views/UnreadableFoldersNotice.swift
index d8940fd0..37563221 100644
--- a/Peel/Views/UnreadableFoldersNotice.swift
+++ b/Peel/Views/UnreadableFoldersNotice.swift
@@ -6,11 +6,16 @@ struct UnreadableFoldersNotice: View {
let folders: [URL]
var body: some View {
+ let paths = folders.map(\.abbreviatedPath)
Notice(
title: Text("Some folders couldn’t be read"),
- detail: Text("Peel couldn’t look inside \(folders.map(\.abbreviatedPath).formatted(.list(type: .and))), so something may be there that isn’t listed here."),
+ detail: Text("Peel couldn’t look inside \(RemovalFailureAlert.listedFolders(paths)), so something may be there that isn’t listed here."),
kind: .note
- ) {}
+ ) {
+ if paths.count > RemovalFailureAlert.mostListed {
+ CopyButton(text: paths.joined(separator: "\n"), title: "Copy Details")
+ }
+ }
.padding(.vertical, 6)
.listRowSeparator(.hidden)
}
diff --git a/PeelTests/UnreadableFoldersTests.swift b/PeelTests/UnreadableFoldersTests.swift
new file mode 100644
index 00000000..c8483f14
--- /dev/null
+++ b/PeelTests/UnreadableFoldersTests.swift
@@ -0,0 +1,14 @@
+@testable import Peel
+import Testing
+
+struct UnreadableFoldersTests {
+ @Test func namesTheFirstFourFoldersAndCountsTheRest() {
+ let paths = (1...60).map { "/Volumes/Old/f\($0)x" }
+
+ let sentence = RemovalFailureAlert.listedFolders(paths)
+
+ #expect(sentence.contains("f4x") && !sentence.contains("f5x") && !sentence.contains("f60x"))
+ #expect(sentence.contains("56"))
+ #expect(RemovalFailureAlert.listedFolders(["/a", "/b"]).contains("/b"))
+ }
+}