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: permission flow hardening + bump to 2.5.1 (build 10)

moamen998cc22b801f
diff --git a/PureMac.xcodeproj/project.pbxproj b/PureMac.xcodeproj/project.pbxproj
index 69cc18c..137626e 100644
--- a/PureMac.xcodeproj/project.pbxproj
+++ b/PureMac.xcodeproj/project.pbxproj
@@ -521,7 +521,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
- CURRENT_PROJECT_VERSION = 9;
+ CURRENT_PROJECT_VERSION = 10;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = H3WXHVTP97;
ENABLE_STRICT_OBJC_MSGSEND = YES;
@@ -543,7 +543,7 @@
GENERATE_INFOPLIST_FILE = NO;
INFOPLIST_FILE = PureMac/Info.plist;
MACOSX_DEPLOYMENT_TARGET = 13.0;
- MARKETING_VERSION = 2.5.0;
+ MARKETING_VERSION = 2.5.1;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = NO;
@@ -645,7 +645,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
COPY_PHASE_STRIP = NO;
- CURRENT_PROJECT_VERSION = 9;
+ CURRENT_PROJECT_VERSION = 10;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEVELOPMENT_TEAM = H3WXHVTP97;
ENABLE_NS_ASSERTIONS = NO;
@@ -661,7 +661,7 @@
GENERATE_INFOPLIST_FILE = NO;
INFOPLIST_FILE = PureMac/Info.plist;
MACOSX_DEPLOYMENT_TARGET = 13.0;
- MARKETING_VERSION = 2.5.0;
+ MARKETING_VERSION = 2.5.1;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = NO;
diff --git a/PureMac/Services/PermissionCoordinator.swift b/PureMac/Services/PermissionCoordinator.swift
index 5d0b8f2..041ca1d 100644
--- a/PureMac/Services/PermissionCoordinator.swift
+++ b/PureMac/Services/PermissionCoordinator.swift
@@ -55,11 +55,21 @@ final class PermissionCoordinator: ObservableObject {
/// Begin the request flow. `onGranted` fires exactly once when permission
/// is detected, regardless of whether the sheet was open or already closed.
+ ///
+ /// Re-entrant: if a request is already in flight, the new context and
+ /// callback replace the previous ones (last writer wins) but the polling
+ /// timer is not duplicated. Prevents a rapid double-tap from spinning up
+ /// two Timers or leaking the first callback's captured state.
func requestAccess(
context: PromptContext = .general,
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.
+ onGrantCallback = nil
+
self.context = context
self.failedItemPaths = failedPaths
self.onGrantCallback = onGranted
@@ -75,6 +85,7 @@ final class PermissionCoordinator: ObservableObject {
}
isRequesting = true
+ // startPolling stops any existing timer first, so re-entry is safe.
startPolling()
}
diff --git a/PureMac/ViewModels/AppState.swift b/PureMac/ViewModels/AppState.swift
index 91ed6f3..33f8e0a 100644
--- a/PureMac/ViewModels/AppState.swift
+++ b/PureMac/ViewModels/AppState.swift
@@ -550,20 +550,25 @@ final class AppState: ObservableObject {
/// Request Full Disk Access via the rich PermissionCoordinator sheet and
/// retry the supplied items once the user grants permission. Used by both
/// the cleanup and app-uninstall flows so they share a single UI surface.
+ ///
+ /// The retry callback captures `items` directly rather than reading
+ /// `pendingPermissionRetryItems` at fire time — that field is mutable
+ /// app-wide and a second permission request would clobber it before the
+ /// first callback resolves, sending the wrong items to retryCleanItems.
func requestFullDiskAccessAndRetry(items: [CleanableItem], context: PermissionCoordinator.PromptContext) {
pendingPermissionRetryItems = items
+ let capturedItems = items
PermissionCoordinator.shared.requestAccess(
context: context,
failedPaths: items.map { $0.path }
) { [weak self] in
Task { @MainActor [weak self] in
guard let self else { return }
- let pending = self.pendingPermissionRetryItems
self.pendingPermissionRetryItems = []
self.cleanError = nil
self.cleanErrorIsFDAFixable = false
- guard !pending.isEmpty else { return }
- await self.retryCleanItems(pending)
+ guard !capturedItems.isEmpty else { return }
+ await self.retryCleanItems(capturedItems)
}
}
}
@@ -608,6 +613,12 @@ final class AppState: ObservableObject {
}
totalJunkSize = categoryResults.values.reduce(0) { $0 + $1.totalSize }
+ // Route survivors back through the same outcome path the original
+ // cleanup uses. Without this, an FDA revocation between grant and
+ // retry would silently drop errors instead of re-popping the sheet.
+ let survivors = items.filter { !result.cleanedPaths.contains($0.path) }
+ handleCleanOutcome(errors: result.errors, survivors: survivors)
+
scanState = .cleaned
loadDiskInfo()
try? await Task.sleep(nanoseconds: 3_000_000_000)
diff --git a/PureMac/Views/OnboardingView.swift b/PureMac/Views/OnboardingView.swift
index be93a3b..7c16f18 100644
--- a/PureMac/Views/OnboardingView.swift
+++ b/PureMac/Views/OnboardingView.swift
@@ -11,6 +11,7 @@ struct OnboardingView: View {
@State private var appeared = false
@State private var hasFda = false
@State private var hasOpenedSettings = false
+ @State private var autoAdvanceScheduled = false
private let pollTimer = Timer.publish(every: 1.0, on: .main, in: .common).autoconnect()
@@ -169,10 +170,20 @@ struct OnboardingView: View {
}
}
// Auto-advance once they grant access while on the permission page.
- if granted, page == .permission {
- DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) {
- advance(by: 1)
+ // The autoAdvanceScheduled latch prevents the 1-second poll from
+ // queueing multiple .8s delays if grants are detected on back-to-back
+ // ticks before the page actually flips.
+ guard granted, page == .permission, !autoAdvanceScheduled else { return }
+ autoAdvanceScheduled = true
+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) {
+ // Re-check page in case the user manually advanced or backed up
+ // during the delay window.
+ guard page == .permission else {
+ autoAdvanceScheduled = false
+ return
}
+ advance(by: 1)
+ autoAdvanceScheduled = false
}
}
}
diff --git a/project.yml b/project.yml
index f829860..41d1574 100644
--- a/project.yml
+++ b/project.yml
@@ -23,8 +23,8 @@ settings:
CODE_SIGN_ENTITLEMENTS: "PureMac/PureMac.entitlements"
INFOPLIST_FILE: "PureMac/Info.plist"
PRODUCT_BUNDLE_IDENTIFIER: "com.puremac.app"
- MARKETING_VERSION: "2.5.0"
- CURRENT_PROJECT_VERSION: "9"
+ MARKETING_VERSION: "2.5.1"
+ CURRENT_PROJECT_VERSION: "10"
GENERATE_INFOPLIST_FILE: "NO"
ASSETCATALOG_COMPILER_APPICON_NAME: "AppIcon"
COMBINE_HIDPI_IMAGES: "YES"