Skip to content

Free, open-source macOS cleaner. CleanMyMac alternative with zero telemetry. Native SwiftUI, scheduled auto-cleaning, Xcode/Homebrew/system cache cleanup. MIT licensed.

fix: pre-release hardening on v2.6.0 surfaces

moamen52d14c2c5061
diff --git a/PureMac/Services/PermissionCoordinator.swift b/PureMac/Services/PermissionCoordinator.swift
index 2193718..8d129aa 100644
--- a/PureMac/Services/PermissionCoordinator.swift
+++ b/PureMac/Services/PermissionCoordinator.swift
@@ -66,10 +66,14 @@ final class PermissionCoordinator: ObservableObject {
failedPaths: [String] = [],
onGranted: @escaping () -> Void
) {
- // Drop the previous callback before installing the new one so its
- // captured state can be released. Without this, a stuck first
- // callback holds AppState slices we just superseded.
+ // Drop the previous callback AND cancel any pending grant work
+ // before installing the new one. Without the cancel, a second
+ // requestAccess() during the 1-second post-grant delay would fire
+ // both callbacks — the queued one for the prior batch plus the
+ // new one we're installing here.
onGrantCallback = nil
+ pendingGrantWork?.cancel()
+ pendingGrantWork = nil
self.context = context
self.failedItemPaths = failedPaths
diff --git a/PureMac/ViewModels/AppState.swift b/PureMac/ViewModels/AppState.swift
index 1d0d099..da167c3 100644
--- a/PureMac/ViewModels/AppState.swift
+++ b/PureMac/ViewModels/AppState.swift
@@ -155,6 +155,15 @@ final class AppState: ObservableObject {
}
func removeSelectedFiles() {
+ // Re-entrance guard: if a previous removal is still resolving and
+ // the FDA sheet hasn't dismissed yet, a second call would race-
+ // overwrite `lastFailedRemovalURLs` before the first batch's retry
+ // closure read it. Refuse the new request until the user dismisses
+ // (or grants and retries) the active sheet.
+ guard !removalNeedsFullDiskAccess else {
+ Logger.shared.log("Refused duplicate removeSelectedFiles while FDA prompt is active", level: .info)
+ return
+ }
// Safety guard: never allow a high-risk home dotpath (listed in
// Conditions.swift) to be trashed no matter how it ended up in the
// selection. Catches selection-time additions that slipped past the
diff --git a/PureMac/Views/Components/AppBundleDragHandle.swift b/PureMac/Views/Components/AppBundleDragHandle.swift
index 06e0e4f..70771da 100644
--- a/PureMac/Views/Components/AppBundleDragHandle.swift
+++ b/PureMac/Views/Components/AppBundleDragHandle.swift
@@ -50,16 +50,16 @@ struct AppBundleDragHandle: View {
.padding(12)
.onHover { hovering = $0 }
.help("Drag this icon into the Full Disk Access list in System Settings.")
- // Standard file-drag pipeline. `NSItemProvider(contentsOf:)` infers
- // the right uniform type (com.apple.application-bundle for an .app)
- // and exposes the URL as a file representation — exactly what
- // System Settings' FDA pane expects from a Finder drop.
+ // NSItemProvider(object: NSURL) is exactly what Finder emits when
+ // you drag an .app — it exposes both the file representation and
+ // the URL string under public.file-url, which is the shape System
+ // Settings' Privacy panes are built to receive. `contentsOf:` works
+ // too but registers as a generic file copy operation; Settings'
+ // FDA list reads the URL representation directly.
.onDrag {
- if let provider = NSItemProvider(contentsOf: bundleURL) {
- provider.suggestedName = bundleURL.lastPathComponent
- return provider
- }
- return NSItemProvider()
+ let provider = NSItemProvider(object: bundleURL as NSURL)
+ provider.suggestedName = bundleURL.lastPathComponent
+ return provider
}
}
diff --git a/PureMac/Views/Components/ConfettiView.swift b/PureMac/Views/Components/ConfettiView.swift
index 41128d2..bd1d0b2 100644
--- a/PureMac/Views/Components/ConfettiView.swift
+++ b/PureMac/Views/Components/ConfettiView.swift
@@ -18,8 +18,10 @@ struct ConfettiView: NSViewRepresentable {
func makeNSView(context: Context) -> NSView {
let host = HostingView()
+ // wantsLayer alone gives AppKit a properly-scaled CALayer with the
+ // window's backing-store scale. Assigning a bare CALayer here would
+ // overwrite that and render particles at 1x on Retina displays.
host.wantsLayer = true
- host.layer = CALayer()
return host
}
@@ -48,11 +50,18 @@ struct ConfettiView: NSViewRepresentable {
// Stop emission after a short burst — particles already in flight
// continue falling and clean up via removeFromSuperlayer below.
- DispatchQueue.main.asyncAfter(deadline: .now() + 1.2) {
- emitter.birthRate = 0
+ // The `[weak self, weak emitter]` capture lets a torn-down view
+ // skip the work entirely so we don't keep allocating particles
+ // against an orphaned layer.
+ DispatchQueue.main.asyncAfter(deadline: .now() + 1.2) { [weak self, weak emitter] in
+ guard self?.window != nil else {
+ emitter?.removeFromSuperlayer()
+ return
+ }
+ emitter?.birthRate = 0
}
- DispatchQueue.main.asyncAfter(deadline: .now() + 4.0) {
- emitter.removeFromSuperlayer()
+ DispatchQueue.main.asyncAfter(deadline: .now() + 4.0) { [weak emitter] in
+ emitter?.removeFromSuperlayer()
}
}
diff --git a/PureMac/Views/OnboardingView.swift b/PureMac/Views/OnboardingView.swift
index e206d9f..4ae8cdd 100644
--- a/PureMac/Views/OnboardingView.swift
+++ b/PureMac/Views/OnboardingView.swift
@@ -435,13 +435,15 @@ private struct ReadyScene: View {
// Fire the welcome confetti exactly once per install.
// Subsequent onboarding re-entries (e.g. after a Reset)
// get a clean ready scene without the celebration.
+ // hasSeenConfetti is recorded the moment the burst
+ // fires (not after it finishes) so a fast user who
+ // clicks Start within the first second still gets the
+ // once-per-install guarantee.
guard !hasSeenConfetti else { return }
DispatchQueue.main.asyncAfter(deadline: .now() + 0.35) {
fireConfetti = true
- Haptics.success()
- }
- DispatchQueue.main.asyncAfter(deadline: .now() + 4.0) {
hasSeenConfetti = true
+ Haptics.success()
}
}