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
Build Artifacts knows a cloud folder by its place and refuses an app
Țugui Dragoș71d272f50217
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstringsindex 516de1ce..7436bc61 100644--- a/Localization/Peel/Localizable.xcstrings+++ b/Localization/Peel/Localizable.xcstrings@@ -49147,6 +49147,112 @@}}},+ "It is an app or another package, or inside one, and what is inside belongs to it." : {+ "localizations" : {+ "cs" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Je to aplikace nebo jiný balíček, nebo se nachází uvnitř některého z nich, a co je uvnitř, patří k němu."+ }+ },+ "de" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Dies ist eine App oder ein anderes Paket oder liegt in einem, und was darin liegt, gehört zum Paket."+ }+ },+ "es" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Es una app u otro paquete, o está dentro de uno, y lo que hay dentro le pertenece."+ }+ },+ "fr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "C’est une app ou un autre paquet, ou il se trouve dans l’un d’eux, et ce qui s’y trouve lui appartient."+ }+ },+ "it" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "È un’app o un altro pacchetto, oppure si trova all’interno di uno di essi, e ciò che contiene appartiene all’app o al pacchetto."+ }+ },+ "ja" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "アプリまたはほかのパッケージであるか、その中にあり、その内容はそのパッケージのものです。"+ }+ },+ "ko" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "앱이나 다른 패키지이거나 그 안에 있으며, 그 안에 있는 항목은 해당 앱이나 패키지에 속합니다."+ }+ },+ "nl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Het is een app of een ander pakket, of het staat in zo’n pakket, en wat erin staat, hoort bij dat pakket."+ }+ },+ "pl" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "To aplikacja lub inny pakiet albo folder wewnątrz jednego z nich, a to, co jest w środku, należy do tej aplikacji lub pakietu."+ }+ },+ "pt" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "É um app ou outro pacote, ou está dentro de um, e o que está dentro pertence a ele."+ }+ },+ "ro" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Este o aplicație sau un alt pachet, ori se află într‑unul, iar conținutul îi aparține."+ }+ },+ "ru" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Это приложение или другой пакет либо папка внутри него, а все, что внутри пакета, принадлежит ему."+ }+ },+ "sv" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Den är en app eller ett annat paket, eller ligger i ett, och det som finns inuti hör till det."+ }+ },+ "tr" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Bir uygulama veya başka bir paket ya da bunlardan birinin içinde; içindekiler ona aittir."+ }+ },+ "uk" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "Це програма або інший пакет чи папка всередині пакета, а вміст пакета належить йому."+ }+ },+ "zh-Hans" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "它是App或其他包,或者位于其中,而其中的内容都属于它。"+ }+ },+ "zh-Hant" : {+ "stringUnit" : {+ "state" : "translated",+ "value" : "它是App或其他套件,或位於其中,而其中的內容屬於該App或套件。"+ }+ }+ }+ },"It is an older version Homebrew kept beside the current one." : {"localizations" : {"cs" : {diff --git a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swiftindex 1298af21..f24ca6a7 100644--- a/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift+++ b/Packages/PeelCore/Sources/PeelCommandLine/Support/Output.swift@@ -327,6 +327,7 @@ extension ProjectArtifacts.Refusal {case .tooBroad: "a whole home folder or disk is too much to search"case .inTheCloud: "it is in a cloud folder, which Peel leaves to the app that syncs it"case .notAFolder: "it isn't a folder Peel can reach"+ case .inAPackage: "it is an app or another package, or inside one, and what is inside belongs to it"}}}diff --git a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swiftindex 4d67c85e..16814671 100644--- a/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift+++ b/Packages/PeelCore/Sources/PeelCore/Developer/ProjectArtifacts.swift@@ -451,6 +451,8 @@ public enum ProjectArtifacts {case tooBroadcase inTheCloudcase notAFolder+ /// An app or another package, or a folder inside one: what is inside belongs to it.+ case inAPackage}/// The folders in the home folder where people usually keep projects, suggested until one is chosen: each is@@ -477,8 +479,11 @@ public enum ProjectArtifacts {for spelling in spellings {var path = spellingwhile path.count > 1, path.hasSuffix("/") { path.removeLast() }- if path.contains("/library/mobile documents") || path.contains("/library/cloudstorage") { return .inTheCloud }let components = PathComponents.of(path)+ let isInACloudFolder = zip(components, components.dropFirst()).contains { folder, inside in+ folder == "library" && ["mobile documents", "cloudstorage"].contains(inside)+ }+ if isInACloudFolder { return .inTheCloud }// A home folder and a volume root both have two components, so they are recognized by name.if components.count < 2 || homes.contains(path) { return .tooBroad }if components.count == 2, ["users", "volumes"].contains(components[0]) { return .tooBroad }@@ -488,7 +493,8 @@ public enum ProjectArtifacts {var isDirectory: ObjCBool = falselet isThere = FileManager.default.fileExists(atPath: PathPattern.comparablePath(of: root), isDirectory: &isDirectory) && isDirectory.boolValue- return isThere ? nil : .notAFolder+ guard isThere else { return .notAFolder }+ return root.isOrIsInsideAPackage ? .inAPackage : nil}static func isSearchable(_ root: URL, home: URL = .homeDirectory) -> Bool {diff --git a/Packages/PeelCore/Sources/PeelCore/Duplicates/DuplicateFinder.swift b/Packages/PeelCore/Sources/PeelCore/Duplicates/DuplicateFinder.swiftindex 85eebff2..37d635b6 100644--- a/Packages/PeelCore/Sources/PeelCore/Duplicates/DuplicateFinder.swift+++ b/Packages/PeelCore/Sources/PeelCore/Duplicates/DuplicateFinder.swift@@ -34,7 +34,9 @@ public struct DuplicateFinder: Sendable {public func canScan(_ folder: URL) -> Bool {let path = Self.path(of: folder.resolvingSymlinksInPath())let home = Self.path(of: homeDirectory)- guard !ProtectedData.refuses(path, home: home), !folder.isInTheCloud, !Self.isInsideAPackage(folder) else { return false }+ guard !ProtectedData.refuses(path, home: home), !folder.isInTheCloud, !folder.isOrIsInsideAPackage else {+ return false+ }if path.isInside(home) {return !Self.managedFolders.contains { path.isInside(home + "/" + $0) }}@@ -44,22 +46,6 @@ public struct DuplicateFinder: Sendable {return (try? folder.resourceValues(forKeys: [.volumeIsReadOnlyKey]).volumeIsReadOnly) != true}- /// Whether `url` is a package, such as an app.- static func isAPackage(_ url: URL) -> Bool {- (try? url.resourceValues(forKeys: [.isPackageKey]).isPackage) == true- }-- /// Whether `url` is a package or sits inside one. What is inside a package belongs to it and is never a copy to- /// offer, and nothing here checks whether an app is running.- static func isInsideAPackage(_ url: URL) -> Bool {- var folder = url.standardizedFileURL- while folder.pathComponents.count > 1 {- if isAPackage(folder) { return true }- folder = folder.deletingLastPathComponent()- }- return false- }-/// Whether `url` is a photo, music, or video library. Its files belong to the library's app, so none of them/// is offered as a copy, whatever its bytes.static func isAUserLibrary(_ url: URL) -> Bool {diff --git a/Packages/PeelCore/Sources/PeelCore/Duplicates/FolderDuplicates.swift b/Packages/PeelCore/Sources/PeelCore/Duplicates/FolderDuplicates.swiftindex 4faff183..198a7ad5 100644--- a/Packages/PeelCore/Sources/PeelCore/Duplicates/FolderDuplicates.swift+++ b/Packages/PeelCore/Sources/PeelCore/Duplicates/FolderDuplicates.swift@@ -166,7 +166,7 @@ struct FolderDuplicates: Sendable {entry,identity: FileIdentity(info),depth: depth + 1,- isNeverOffered: isNeverOffered || Self.isHidden(entry, info) || DuplicateFinder.isAPackage(entry),+ isNeverOffered: isNeverOffered || Self.isHidden(entry, info) || entry.isAPackage,onListing: onListing)guard !child.isProject else {diff --git a/Packages/PeelCore/Sources/PeelCore/Support/RealFolder.swift b/Packages/PeelCore/Sources/PeelCore/Support/RealFolder.swiftindex fa5aec49..51dad0d6 100644--- a/Packages/PeelCore/Sources/PeelCore/Support/RealFolder.swift+++ b/Packages/PeelCore/Sources/PeelCore/Support/RealFolder.swift@@ -27,4 +27,19 @@ extension URL {var isInTheCloud: Bool {(try? resourceValues(forKeys: [.isUbiquitousItemKey]).isUbiquitousItem) == true}++ /// Whether this is a package, such as an app.+ var isAPackage: Bool {+ (try? resourceValues(forKeys: [.isPackageKey]).isPackage) == true+ }++ /// Whether this is a package or sits inside one. What is inside a package belongs to it.+ var isOrIsInsideAPackage: Bool {+ var folder = standardizedFileURL+ while folder.pathComponents.count > 1 {+ if folder.isAPackage { return true }+ folder = folder.deletingLastPathComponent()+ }+ return false+ }}diff --git a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swiftindex 61c03093..f7f2e950 100644--- a/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift+++ b/Packages/PeelCore/Tests/PeelCoreTests/ProjectArtifactsTests.swift@@ -503,6 +503,20 @@ struct ProjectArtifactsTests {#expect(ProjectArtifacts.refusal(for: home.appending(path: "Library/CLOUDSTORAGE/Dropbox"), home: home) == .inTheCloud)}+ /// A cloud folder is known by its place, never by a name that only begins like one. What is inside an app or+ /// another package belongs to it, as an Electron app keeps `package.json` beside `node_modules` in its bundle.+ @Test func refusesACloudFolderByItsPlaceAndAPackageByWhatItIs() throws {+ let directory = try TemporaryDirectory()+ let home = URL(filePath: "/Users/x", directoryHint: .isDirectory)+ let kit = try directory.directory("Code/Library/CloudStorageKit")+ try directory.file("Sample.app/Contents/Resources/app/package.json")+ let app = directory.url.appending(path: "Sample.app", directoryHint: .isDirectory)++ #expect(ProjectArtifacts.refusal(for: kit, home: home) == nil)+ #expect(ProjectArtifacts.refusal(for: app, home: home) == .inAPackage)+ #expect(ProjectArtifacts.refusal(for: app.appending(path: "Contents/Resources/app"), home: home) == .inAPackage)+ }+@Test func refusesRootsThatAreTooBroadOrNotOurs() {#expect(!ProjectArtifacts.isSearchable(URL(filePath: "/")))#expect(!ProjectArtifacts.isSearchable(URL(filePath: "/Users")))diff --git a/Peel/Views/Presentation.swift b/Peel/Views/Presentation.swiftindex a91cdfc0..638f4ea4 100644--- a/Peel/Views/Presentation.swift+++ b/Peel/Views/Presentation.swift@@ -165,6 +165,7 @@ extension ProjectArtifacts.Refusal {case .tooBroad: String(localized: "A whole home folder or disk is too much to search. Choose the folder your projects are in.")case .inTheCloud: String(localized: "It is in iCloud Drive or another cloud folder, which Peel leaves to the app that syncs it.")case .notAFolder: String(localized: "It isn’t a folder Peel can reach. A disk that isn’t connected looks like this too.")+ case .inAPackage: String(localized: "It is an app or another package, or inside one, and what is inside belongs to it.")}}}