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
Read Intel Software again quietly
Țugui Dragoșcc95b4870af2
diff --git a/Peel/Model/IntelLibrary.swift b/Peel/Model/IntelLibrary.swiftindex 8d660ce9..02818eb7 100644--- a/Peel/Model/IntelLibrary.swift+++ b/Peel/Model/IntelLibrary.swift@@ -16,17 +16,40 @@ final class IntelLibrary {var findings: [IntelFinding] { scan?.findings ?? [] }- /// Scans everything the report covers, so it is complete even when the other pages were never opened.- func refresh(installedApps: [InstalledApp]) async {- guard let result = await scanRun.run({- let exclusions = ExclusionsStore.shared.exclusions+ private let read: @MainActor ([InstalledApp], Exclusions) async -> IntelScan++ /// `read` scans everything the report covers, so it is complete even when the other pages were never opened.+ init(+ read: @escaping @MainActor ([InstalledApp], Exclusions) async -> IntelScan = { installedApps, exclusions inasync let backgroundItems = BackgroundItems.scan(exclusions: exclusions)return await IntelInspector.scan(installedApps: installedApps,backgroundItems: backgroundItems,exclusions: exclusions)- }) else { return }+ }+ ) {+ self.read = read+ }++ func refresh(installedApps: [InstalledApp]) async {+ let read = read+ guard let result = await scanRun.run({ await read(installedApps, ExclusionsStore.shared.exclusions) }) else {+ return+ }+ show(result)+ }++ /// Reads the page again without showing a scan, once it has been read.+ func readAgain(installedApps: [InstalledApp]) async {+ guard scan != nil else { return }+ let read = read+ guard let result = await scanRun.runQuietly({ await read(installedApps, ExclusionsStore.shared.exclusions) })+ else { return }+ show(result)+ }++ private func show(_ result: IntelScan) {scan = resultif let selection, !result.findings.contains(where: { $0.id == selection }) {self.selection = nildiff --git a/Peel/Views/Intel/IntelList.swift b/Peel/Views/Intel/IntelList.swiftindex 5c2b99f7..9d628d9a 100644--- a/Peel/Views/Intel/IntelList.swift+++ b/Peel/Views/Intel/IntelList.swift@@ -81,15 +81,20 @@ struct IntelList: View {}}}- // What the page lists can change from other pages and other apps, and a scan costs little, so it looks again- // each time it is shown and each time Peel comes forward.+ // What the page lists can change from other pages and other apps, and a scan costs little, so once read it+ // looks again, quietly, each time it is shown and each time Peel comes forward..task(id: library.revision) {- guard library.hasLoaded, !(intel.scan == nil && intel.scanRun.wasStopped) else { return }+ guard library.hasLoaded else { return }+ guard intel.scan == nil else {+ await intel.readAgain(installedApps: library.apps)+ return+ }+ guard !intel.scanRun.wasStopped else { return }await scan()}.onReceive(NotificationCenter.default.publisher(for: NSApplication.didBecomeActiveNotification)) { _ in- guard library.hasLoaded, !(intel.scan == nil && intel.scanRun.wasStopped) else { return }- Task { await scan() }+ guard library.hasLoaded else { return }+ Task { await intel.readAgain(installedApps: library.apps) }}.rescanOnExclusionChange("IntelList") { await scan() }}diff --git a/PeelTests/IntelLibraryTests.swift b/PeelTests/IntelLibraryTests.swiftnew file mode 100644index 00000000..2f7b3b8f--- /dev/null+++ b/PeelTests/IntelLibraryTests.swift@@ -0,0 +1,33 @@+import Foundation+@testable import Peel+@testable import PeelCore+import Testing++@MainActor+struct IntelLibraryTests {+ private final class Reads {+ var count = 0+ var library: IntelLibrary?+ var wereShownAsAScan: [Bool] = []+ }++ @Test func readsAgainWithoutShowingAScan() async {+ let reads = Reads()+ let unread = URL(filePath: "/org.example/Vendor")+ let library = IntelLibrary { _, _ in+ reads.count += 1+ reads.wereShownAsAScan.append(reads.library?.isScanning == true)+ return IntelScan(findings: [], unreadable: reads.count > 1 ? [unread] : [])+ }+ reads.library = library++ await library.readAgain(installedApps: [])+ #expect(reads.count == 0, "nothing is read again before the page was read once")++ await library.refresh(installedApps: [])+ await library.readAgain(installedApps: [])++ #expect(library.scan?.unreadable == [unread])+ #expect(reads.wereShownAsAScan == [true, false], "a read again is announced to nobody")+ }+}