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.

List no orphaned files in the app while some apps can't be read

Țugui Dragoș5bc7c86f3625
diff --git a/Localization/Peel/Localizable.xcstrings b/Localization/Peel/Localizable.xcstrings
index fbeb051d..47e69860 100644
--- a/Localization/Peel/Localizable.xcstrings
+++ b/Localization/Peel/Localizable.xcstrings
@@ -79464,6 +79464,112 @@
}
}
},
+ "Not Every App Could Be Read" : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Ne všechny aplikace se podařilo přečíst"
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nicht jede App konnte gelesen werden"
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "No se han podido leer todas las apps"
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Toutes les apps n’ont pas pu être lues"
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Non è stato possibile leggere tutte le app"
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "一部のアプリを読み取れませんでした"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "일부 앱을 읽을 수 없음"
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Niet elke app kon worden gelezen"
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nie wszystkie aplikacje udało się odczytać"
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nem Todo App Pôde Ser Lido"
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Nu toate aplicațiile au putut fi citite"
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Не все приложения удалось прочитать"
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Alla appar kunde inte läsas"
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Bazı Uygulamalar Okunamadı"
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Не всі програми вдалося прочитати"
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "未能读取全部App"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "部分App無法讀取"
+ }
+ }
+ }
+ },
"Not Everything Could Be Read" : {
"localizations" : {
"cs" : {
@@ -93173,6 +93279,112 @@
}
}
},
+ "Peel can’t read its list of app folders, so Orphaned Files lists nothing. Starting over keeps the old list beside a new one." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nemůže přečíst svůj seznam složek aplikací, takže stránka Osiřelé soubory nic nezobrazuje. Když začnete znovu, starý seznam se ponechá vedle nového."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel kann seine Liste der App-Ordner nicht lesen, daher zeigt die Seite „Verwaiste Dateien“ nichts an. Wenn du neu beginnst, bleibt die alte Liste neben einer neuen erhalten."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel no puede leer su lista de carpetas de apps, así que la página Archivos huérfanos no muestra nada. Al volver a empezar, la lista antigua se conserva junto a una nueva."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel ne peut pas lire sa liste de dossiers d’apps : la page Fichiers orphelins ne liste donc rien. Si vous recommencez, l’ancienne liste est conservée à côté d’une nouvelle."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel non riesce a leggere il suo elenco di cartelle delle app, quindi “File orfani” non elenca nulla. Se ricominci da capo, il vecchio elenco viene conservato accanto a uno nuovo."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peelはアプリのフォルダのリストを読み取れないため、“孤立ファイル”には何も表示されません。最初からやり直すと、古いリストは新しいリストの横に保管されます。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel이 앱 폴더 목록을 읽을 수 없으므로 주인 없는 파일 페이지는 아무것도 나열하지 않습니다. 처음부터 다시 시작하면 이전 목록은 새 목록 옆에 보관됩니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel kan zijn lijst van mappen met apps niet lezen, dus toont de pagina 'Verweesde bestanden' niets. Als je opnieuw begint, wordt de oude lijst naast een nieuwe lijst bewaard."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nie może odczytać swojej listy folderów z aplikacjami, więc strona Osierocone pliki niczego nie wyświetla. Gdy zaczniesz od nowa, stara lista zostanie zachowana obok nowej."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O Peel não consegue ler a lista de pastas de apps, então a página Arquivos Órfãos não lista nada. Ao recomeçar, a lista antiga é guardada ao lado de uma nova."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nu își poate citi lista de dosare de aplicații, așa că pagina Fișiere orfane nu listează nimic. Dacă reîncepeți lista, cea veche este păstrată lângă una nouă."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не удается прочитать свой список папок приложений, поэтому раздел «Осиротевшие файлы» ничего не показывает. Если начать заново, старый список сохранится рядом с новым."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel kan inte läsa sin lista över appmappar, så sidan Övergivna filer listar ingenting. När du börjar om sparas den gamla listan bredvid en ny."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel, uygulama klasörleri listesini okuyamıyor, bu yüzden Sahipsiz Dosyalar hiçbir şey listelemiyor. Baştan başladığınızda eski liste yeni bir listenin yanında saklanır."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не може прочитати свій список папок програм, тож розділ «Покинуті файли» нічого не показує. Коли ви починаєте наново, старий список зберігається поруч із новим."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel无法读取其App文件夹列表,因此“孤立文件”不会列出任何内容。重新开始会将旧列表保留在新列表旁边。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel無法讀取它的App檔案夾列表,因此「孤立檔案」不會列出任何項目。重新開始時,舊列表會保留在新列表旁邊。"
+ }
+ }
+ }
+ },
"Peel can’t read its record of who signs your apps" : {
"localizations" : {
"cs" : {
@@ -95019,6 +95231,112 @@
}
}
},
+ "Peel couldn’t read %@, so it can’t tell which apps are installed. Nothing is listed here, since the files of an app it can’t see would look orphaned." : {
+ "localizations" : {
+ "cs" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nemohl přečíst %@, takže nemůže určit, které aplikace jsou nainstalované. Nic tu není uvedeno, protože by soubory aplikace, kterou Peel nevidí, vypadaly jako osiřelé."
+ }
+ },
+ "de" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel konnte %@ nicht lesen und kann daher nicht erkennen, welche Apps installiert sind. Hier wird nichts aufgeführt, da die Dateien einer App, die Peel nicht sehen kann, verwaist wirken würden."
+ }
+ },
+ "es" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel no ha podido leer %@, así que no puede saber qué apps hay instaladas. Aquí no aparece nada, ya que los archivos de una app que Peel no puede ver parecerían huérfanos."
+ }
+ },
+ "fr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel n’a pas pu lire %@ : il ne peut donc pas savoir quelles apps sont installées. Rien n’est listé ici, car les fichiers d’une app qu’il ne peut pas voir sembleraient orphelins."
+ }
+ },
+ "it" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel non è riuscito a leggere %@, quindi non può sapere quali app sono installate. Qui non è elencato nulla, perché i file di un’app che Peel non vede sembrerebbero orfani."
+ }
+ },
+ "ja" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peelは%@を読み取れなかったため、どのアプリがインストールされているかを判断できません。ここに何も表示されていないのは、Peelが確認できないアプリのファイルが孤立ファイルに見えてしまうためです。"
+ }
+ },
+ "ko" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel이 %@을(를) 읽을 수 없었으므로 어떤 앱이 설치되어 있는지 알 수 없습니다. Peel이 볼 수 없는 앱의 파일이 주인 없는 파일처럼 보이게 되므로 여기에는 아무것도 나열되지 않습니다."
+ }
+ },
+ "nl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel kon %@ niet lezen en kan dus niet nagaan welke apps er geïnstalleerd zijn. Hier wordt niets getoond, omdat de bestanden van een app die Peel niet kan zien, verweesd zouden lijken."
+ }
+ },
+ "pl" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nie mógł odczytać %@, więc nie może ustalić, które aplikacje są zainstalowane. Niczego tu nie wyświetla, ponieważ pliki aplikacji, której nie widzi, wyglądałyby na osierocone."
+ }
+ },
+ "pt" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "O Peel não conseguiu ler %@, então não sabe dizer quais apps estão instalados. Nada aparece aqui, porque os arquivos de um app que ele não consegue ver pareceriam órfãos."
+ }
+ },
+ "ro" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel nu a putut citi %@, așa că nu poate ști ce aplicații sunt instalate. Aici nu este listat nimic, deoarece fișierele unei aplicații pe care nu o poate vedea ar părea orfane."
+ }
+ },
+ "ru" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не удалось прочитать %@, поэтому он не может определить, какие приложения установлены. Здесь ничего не показано, так как файлы приложения, которого Peel не видит, выглядели бы осиротевшими."
+ }
+ },
+ "sv" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel kunde inte läsa %@, så Peel kan inte avgöra vilka appar som är installerade. Inget listas här, eftersom filerna från en app som Peel inte kan se skulle verka övergivna."
+ }
+ },
+ "tr" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel şunları okuyamadı: %@. Bu yüzden hangi uygulamaların yüklü olduğunu bilemiyor. Burada hiçbir şey listelenmiyor, çünkü Peel’in göremediği bir uygulamanın dosyaları sahipsiz görünürdü."
+ }
+ },
+ "uk" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel не змогла прочитати %@, тож не може визначити, які програми інстальовано. Тут нічого не показано, бо файли програми, якої Peel не бачить, здавалися б покинутими."
+ }
+ },
+ "zh-Hans" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel未能读取%@,因此无法判断安装了哪些App。此处没有列出任何内容,因为如果Peel看不到某个App,该App的文件看起来就会像孤立文件。"
+ }
+ },
+ "zh-Hant" : {
+ "stringUnit" : {
+ "state" : "translated",
+ "value" : "Peel無法讀取%@,因此無法判斷哪些App已安裝。此處沒有列出任何項目,因為Peel看不到的App,其檔案看起來會像孤立檔案。"
+ }
+ }
+ }
+ },
"Peel couldn’t read History" : {
"localizations" : {
"cs" : {
diff --git a/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swift b/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swift
index 9940dfb2..703f3a78 100644
--- a/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swift
+++ b/Packages/PeelCore/Sources/PeelCore/Apps/AppFolders.swift
@@ -37,6 +37,15 @@ public struct AppFolders: Sendable {
}
}
+ /// Sets a list that cannot be read aside, under another name, so the folders can be chosen again. False when it
+ /// stays where it is.
+ @discardableResult
+ public func startOver() -> Bool {
+ FileLock.whileHeld(beside: url) {
+ url.isMissing || read() != nil || DamagedFile.setAside(url) != nil
+ }
+ }
+
@discardableResult
public func remove(_ folders: [URL]) -> Bool {
let removed = Set(folders.map { PathPattern.comparablePath(of: $0) })
diff --git a/Packages/PeelCore/Tests/PeelCoreTests/AppFoldersTests.swift b/Packages/PeelCore/Tests/PeelCoreTests/AppFoldersTests.swift
index 45c5cdc2..aa22c7c5 100644
--- a/Packages/PeelCore/Tests/PeelCoreTests/AppFoldersTests.swift
+++ b/Packages/PeelCore/Tests/PeelCoreTests/AppFoldersTests.swift
@@ -44,4 +44,16 @@ struct AppFoldersTests {
#expect(AppFolders(url: closed).load() == nil)
#expect(AppFolders(url: directory.url.appending(path: "missing.json")).load() == [])
}
+
+ @Test func startingOverKeepsTheDamagedListBesideAnEmptyOne() throws {
+ let directory = try TemporaryDirectory()
+ let folders = AppFolders(url: try directory.file("app-folders.json", contents: Data("not a list".utf8)))
+
+ #expect(folders.startOver())
+
+ #expect(folders.load() == [])
+ let kept = try FileManager.default.contentsOfDirectory(atPath: directory.url.path(percentEncoded: false))
+ .filter { $0.hasPrefix("app-folders-damaged-") }
+ #expect(kept.count == 1)
+ }
}
diff --git a/Peel/Model/AppLibrary.swift b/Peel/Model/AppLibrary.swift
index 65f4b0f8..4bee6b2e 100644
--- a/Peel/Model/AppLibrary.swift
+++ b/Peel/Model/AppLibrary.swift
@@ -75,10 +75,15 @@ final class AppLibrary {
private(set) var lastOpenedRevision = 0
private(set) var isLoading = false
private(set) var hasLoaded = false
- /// The folders the person chose for apps, beside the Applications folders. `PeelApp` watches them and reads the
- /// apps again when they change.
- private(set) var folders = AppFolders().load() ?? []
+ /// The folders the person chose for apps, beside the Applications folders, or nil when their list cannot be read.
+ /// `PeelApp` watches them and reads the apps again when they change.
+ private(set) var folders = AppFolders().load()
private(set) var couldNotSaveFolders = false
+ /// What the last reading of the folders could not read, so the apps in it are missing from `apps`
+ /// (`AppScan.unreadable`).
+ private(set) var unreadable: [URL] = []
+ /// Whether Full Disk Access would open what the last reading could not read.
+ private(set) var unreadableNeedsFullDiskAccess = false
private(set) var updateStatuses: [InstalledApp.ID: UpdateStatus] = [:] {
didSet { updatesRevision += 1 }
}
@@ -176,20 +181,31 @@ final class AppLibrary {
shown.count > 1
}
+ /// The apps listed, and what could not be read of them, which Orphaned Files checks its files against.
+ struct Listing: Equatable {
+ let revision: Int
+ let unreadable: [URL]
+ }
+
+ var listing: Listing {
+ Listing(revision: revision, unreadable: unreadable)
+ }
+
/// The first reading of the folders, at launch. A reading the folder watch starts meanwhile takes its place
/// and lists the apps itself.
func load() async {
isLoading = true
lastRead = .now
- let found = await scanRun.run { await AppCatalog.installedApps() }
+ let found = await scanRun.run { await AppCatalog.scan() }
if let found {
- adopt(found)
+ keepUnreadable(of: found)
+ adopt(found.apps)
}
recall()
isLoading = false
hasLoaded = true
if let found {
- await AppMemory().remember(found)
+ await AppMemory().remember(found.apps)
}
}
@@ -208,10 +224,15 @@ final class AppLibrary {
changeFolders { $0.remove(urls) }
}
+ /// Sets the list of folders aside when it cannot be read, so the folders can be chosen again.
+ func startFoldersOver() {
+ changeFolders { $0.startOver() }
+ }
+
private func changeFolders(_ change: (AppFolders) -> Bool) {
let store = AppFolders()
couldNotSaveFolders = !change(store)
- folders = store.load() ?? []
+ folders = store.load()
}
/// Reads the folders again without emptying the list first, so an app installed while Peel is open
@@ -222,8 +243,10 @@ final class AppLibrary {
/// when it was last checked) is dropped rather than shown for a version it doesn't describe.
@discardableResult
func refresh() async -> [InstalledApp] {
- guard let found = await scanRun.run({ await AppCatalog.installedApps() }) else { return [] }
+ guard let scan = await scanRun.run({ await AppCatalog.scan() }) else { return [] }
lastRead = .now
+ keepUnreadable(of: scan)
+ let found = scan.apps
let listed = AppCatalog.sorted(found + stillThere(revealed, beside: found))
guard listed != apps else { return [] }
guard !AppCatalog.listsTheSameApps(listed, as: apps) else {
@@ -246,6 +269,13 @@ final class AppLibrary {
await checkSigningTeams()
}
+ private func keepUnreadable(of scan: AppScan) {
+ if unreadable != scan.unreadable { unreadable = scan.unreadable }
+ if unreadableNeedsFullDiskAccess != scan.needsFullDiskAccess {
+ unreadableNeedsFullDiskAccess = scan.needsFullDiskAccess
+ }
+ }
+
/// Takes a new reading of the folders and returns the apps whose build changed. Drops whatever was cached
/// about an app that is gone or a build that was replaced, so an app removed and installed again never
/// shows the old copy's size or update status. Both `load()` and `refresh()` come through here.
diff --git a/Peel/Model/OrphanLibrary.swift b/Peel/Model/OrphanLibrary.swift
index 11bc6018..ad49d431 100644
--- a/Peel/Model/OrphanLibrary.swift
+++ b/Peel/Model/OrphanLibrary.swift
@@ -13,8 +13,8 @@ final class OrphanLibrary {
var selection: OrphanGroup.ID?
var selectedURLs: Set<URL> = []
- /// The revision of the apps list the scan was checked against. The page scans again when the list changes.
- private(set) var scannedRevision: Int?
+ /// The apps list the scan was checked against. The page scans again when the list changes.
+ private(set) var scannedAgainst: AppLibrary.Listing?
/// The groups the person said belong to an app, by identifier, with that app's bundle identifier.
private(set) var owners = OrphanOwners().load()
@@ -27,10 +27,20 @@ final class OrphanLibrary {
}
func refresh(from library: AppLibrary) async {
+ // An app that could not be read is missing from the list, and its files would look orphaned, so nothing is
+ // listed until every app can be read.
+ let listing = library.listing
+ guard listing.unreadable.isEmpty else {
+ scan = nil
+ selection = nil
+ selectedURLs = []
+ scannedAgainst = listing
+ return
+ }
// Until the apps are read, no folder has an owner, so every folder would look orphaned. The callers
// check this too; checking here keeps a new caller from getting it wrong.
guard !library.apps.isEmpty else { return }
- let (installedApps, revision) = (library.apps, library.revision)
+ let installedApps = library.apps
let owners = OrphanOwners().load()
self.owners = owners
guard let result = await scanRun.run({
@@ -40,10 +50,10 @@ final class OrphanLibrary {
let running = Set(NSWorkspace.shared.runningApplications.compactMap(\.bundleIdentifier))
return await OrphanScanner(exclusions: ExclusionsStore.shared.exclusions)
.scan(installedApps: installedApps, remembered: remembered, running: running, owners: owners)
- }) else { return }
+ }), library.unreadable.isEmpty else { return }
let remainingURLs = Set(result.groups.flatMap(\.items).filter { $0.leftAlone == nil }.map(\.url))
scan = result
- scannedRevision = revision
+ scannedAgainst = listing
selectedURLs.formIntersection(remainingURLs)
if let selection, !result.groups.contains(where: { $0.id == selection }) {
self.selection = nil
diff --git a/Peel/PeelApp.swift b/Peel/PeelApp.swift
index e4f243c2..a1920dd3 100644
--- a/Peel/PeelApp.swift
+++ b/Peel/PeelApp.swift
@@ -116,7 +116,9 @@ struct PeelApp: App {
for await folders in Observations({ library.folders }) {
let foldersChanged = watch != nil
watch?.cancel()
- watch = Task { await followApps(in: AppCatalog.directories(adding: folders), readingNow: foldersChanged) }
+ watch = Task {
+ await followApps(in: AppCatalog.directories(adding: folders ?? []), readingNow: foldersChanged)
+ }
}
}
diff --git a/Peel/Views/AppList.swift b/Peel/Views/AppList.swift
index cd9532a4..db8572fd 100644
--- a/Peel/Views/AppList.swift
+++ b/Peel/Views/AppList.swift
@@ -19,6 +19,11 @@ struct AppList: View {
if let problem = library.teamRecordProblem {
TeamRecordNotice(problem: problem)
}
+ if library.unreadableNeedsFullDiskAccess {
+ FullDiskAccessBanner()
+ } else if !library.unreadable.isEmpty {
+ UnreadableFoldersNotice(folders: library.unreadable)
+ }
if visible.waiting.isEmpty {
ForEach(visible.rest, content: row)
} else {
diff --git a/Peel/Views/Orphans/OrphanList.swift b/Peel/Views/Orphans/OrphanList.swift
index e1e49df5..cbef3a53 100644
--- a/Peel/Views/Orphans/OrphanList.swift
+++ b/Peel/Views/Orphans/OrphanList.swift
@@ -26,7 +26,23 @@ struct OrphanList: View {
}
}
.scanState(phase(filtered), isRescanning: isRescanning, scan: orphans.scanRun) {
- if orphans.scan?.groups.isEmpty == true, let unreadable = orphans.scan?.unreadableLocations,
+ if !library.unreadable.isEmpty {
+ ContentUnavailableView {
+ Label("Not Every App Could Be Read", systemImage: "exclamationmark.triangle")
+ } description: {
+ let unread = Text("Peel couldn’t read \(library.unreadable.map(\.abbreviatedPath).formatted(.list(type: .and))), so it can’t tell which apps are installed. Nothing is listed here, since the files of an app it can’t see would look orphaned.")
+ if library.unreadableNeedsFullDiskAccess {
+ let access = Text("Give Peel Full Disk Access so it can read the folders macOS protects.")
+ Text("\(unread)\n\n\(access)")
+ } else {
+ unread
+ }
+ } actions: {
+ if library.unreadableNeedsFullDiskAccess {
+ Button("Open System Settings") { home.openFullDiskAccessSettings() }
+ }
+ }
+ } else if orphans.scan?.groups.isEmpty == true, let unreadable = orphans.scan?.unreadableLocations,
!unreadable.isEmpty {
ContentUnavailableView {
Label("Not Everything Could Be Read", systemImage: "exclamationmark.triangle")
@@ -57,7 +73,8 @@ struct OrphanList: View {
.announcesScan(
orphans.isScanning,
found: orphans.summary,
- couldNotLook: orphans.scan?.unreadableLocations.isEmpty == false ? "Not Everything Could Be Read" : nil,
+ couldNotLook: !library.unreadable.isEmpty ? "Not Every App Could Be Read"
+ : orphans.scan?.unreadableLocations.isEmpty == false ? "Not Everything Could Be Read" : nil,
wasStopped: orphans.scanRun.wasStopped
)
.toolbar {
@@ -67,14 +84,18 @@ struct OrphanList: View {
isDisabled: !library.hasLoaded || orphans.isRemoving,
scan: orphans.scanRun
) {
+ // What could not be read may be readable now, so the apps are read again first.
+ if !library.unreadable.isEmpty {
+ await library.checkAgain(await library.refresh())
+ }
await orphans.refresh(from: library)
}
}
}
- // Scans again whenever the installed apps change, since a list made before an app was installed would
- // call that app's files orphaned. It never restarts a first scan the user stopped.
- .task(id: library.revision) {
- guard library.hasLoaded, orphans.scannedRevision != library.revision,
+ // Scans again whenever the installed apps change, or what could not be read of them, since a list made before
+ // an app was installed would call that app's files orphaned. It never restarts a first scan the user stopped.
+ .task(id: library.listing) {
+ guard library.hasLoaded, orphans.scannedAgainst != library.listing,
!(orphans.scan == nil && orphans.scanRun.wasStopped)
else { return }
await orphans.refresh(from: library)
@@ -83,6 +104,7 @@ struct OrphanList: View {
}
private func phase(_ filtered: [OrphanGroup]) -> ScanPhase {
+ if !library.unreadable.isEmpty { return .message }
if orphans.scan == nil { return orphans.scanRun.wasStopped ? .stopped : .scanning(.walk) }
if orphans.scan?.groups.isEmpty == true { return .message }
if filtered.isEmpty, !searchText.isEmpty { return .message }
diff --git a/Peel/Views/Settings/AppFoldersSection.swift b/Peel/Views/Settings/AppFoldersSection.swift
index c3e3ba27..b7c7a0fc 100644
--- a/Peel/Views/Settings/AppFoldersSection.swift
+++ b/Peel/Views/Settings/AppFoldersSection.swift
@@ -14,12 +14,9 @@ struct AppFoldersSection: View {
var body: some View {
Section {
- if library.folders.isEmpty {
- Text("No other folder is on this list yet.")
- .foregroundStyle(.secondary)
- } else {
+ if let folders = library.folders, !folders.isEmpty {
List(selection: $selected) {
- ForEach(library.folders, id: \.self) { folder in
+ ForEach(folders, id: \.self) { folder in
HStack(spacing: 8) {
AppIcon(url: folder)
.frame(width: 16, height: 16)
@@ -30,9 +27,18 @@ struct AppFoldersSection: View {
.tag(folder)
}
}
- .frame(height: settingsListHeight(rows: library.folders.count))
+ .frame(height: settingsListHeight(rows: folders.count))
.scrollContentBackground(.hidden)
.onDeleteCommand { removeSelected() }
+ } else if library.folders != nil {
+ Text("No other folder is on this list yet.")
+ .foregroundStyle(.secondary)
+ } else {
+ HStack {
+ WarningLabel(title: Text("Peel can’t read its list of app folders, so Orphaned Files lists nothing. Starting over keeps the old list beside a new one."))
+ Spacer()
+ Button("Start Over") { library.startFoldersOver() }
+ }
}
if library.couldNotSaveFolders {
WarningLabel(title: Text("Peel couldn’t save the app folders."))