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.

Look in a Downloads folder moved elsewhere, and once

Țugui Dragoș09d0c5b9ce9c
diff --git a/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift b/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift
index af439b80..7cb2f155 100644
--- a/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Space/Installers.swift
@@ -164,12 +164,17 @@ public enum Installers {
} + [Folder(url: root.appending(path: "Users/Shared", directoryHint: .isDirectory), isSharedWithEveryone: true)]
let origins = DownloadOrigins.inHome(home).reader()
var folders: [Folder] = []
+ var listed: Set<String> = []
// A scan its page left asks nothing more: reading a folder macOS guards puts up macOS's question again.
for place in places {
guard !Task.isCancelled else { break }
- if canList(place.url) == .missing { unreadable.append(place.url) }
- folders += [place] + subfolders(of: place.url).map {
- Folder(url: $0, isSharedWithEveryone: place.isSharedWithEveryone)
+ // Listing a link as a URL answers "Not a directory", so a folder moved elsewhere is read where it leads,
+ // and once if that is inside another place.
+ let url = place.url.isSymbolicLink ? PathPattern.canonical(place.url) : place.url
+ if canList(url) == .missing { unreadable.append(place.url) }
+ for folder in [url] + subfolders(of: url)
+ where listed.insert(PathPattern.comparablePath(of: PathPattern.canonical(folder))).inserted {
+ folders.append(Folder(url: folder, isSharedWithEveryone: place.isSharedWithEveryone))
}
}
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift
index 6d4ad4eb..142ab152 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/InstallersTests.swift
@@ -693,6 +693,36 @@ struct InstallersTests {
#expect(scan.items(in: .firmware).map(\.name) == ["iPhone17,1_26.1.ipsw"])
}
+ @Test func aPlaceThatLeadsIntoAnotherListsWhatIsThereOnce() async throws {
+ let directory = try TemporaryDirectory()
+ let moved = try directory.directory("Documents/Downloads")
+ try directory.file("Documents/Downloads/Tool-1.dmg", bytes: 400_000)
+ try FileManager.default.createSymbolicLink(
+ at: directory.url.appending(path: "Downloads"), withDestinationURL: moved
+ )
+ try directory.directory("Applications")
+
+ let scan = await Installers.scan(
+ installedApps: [], home: directory.url, root: directory.url, minimumSize: 100_000
+ )
+
+ #expect(scan.items.map(\.name) == ["Tool-1.dmg"])
+ }
+
+ @Test func aPlaceThatLeadsElsewhereIsLookedIn() async throws {
+ let directory = try TemporaryDirectory()
+ let home = try directory.directory("home")
+ let disk = try directory.directory("Disk/Downloads")
+ try directory.file("Disk/Downloads/Tool-1.dmg", bytes: 400_000)
+ try FileManager.default.createSymbolicLink(at: home.appending(path: "Downloads"), withDestinationURL: disk)
+
+ let scan = await Installers.scan(
+ installedApps: [], home: home, root: directory.url, minimumSize: 100_000
+ )
+
+ #expect(scan.items.map(\.name) == ["Tool-1.dmg"])
+ }
+
@Test func aMacOSInstallerWithABlankVersionNotesNone() async throws {
let directory = try TemporaryDirectory()
for (name, version) in [("Install macOS Tahoe", ""), ("Install macOS Sequoia", "15.6")] {