diff --git a/SUAutomaticUpdateDriver.m b/SUAutomaticUpdateDriver.m index 61018962..41e5503c 100644 --- a/SUAutomaticUpdateDriver.m +++ b/SUAutomaticUpdateDriver.m @@ -19,6 +19,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 - (void)showUpdateAlert { + isInterruptible = NO; alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:updateItem host:host delegate:self]; // If the app is a menubar app or the like, we need to focus it first and alter the @@ -69,6 +70,9 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 else { showUpdateAlertTimer = [[NSTimer scheduledTimerWithTimeInterval:SUAutomaticUpdatePromptImpatienceTimer target:self selector:@selector(showUpdateAlert) userInfo:nil repeats:NO] retain]; + + // At this point the driver is idle, allow it to be interrupted for user-initiated update checks. + isInterruptible = YES; } } @@ -126,7 +130,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 break; case SUInstallLaterChoice: - // No-op: we're already waiting on quit. + // We're already waiting on quit, just indicate that we're idle. + isInterruptible = YES; break; case SUDoNotInstallChoice: diff --git a/SUUpdateDriver.h b/SUUpdateDriver.h index 1a305d11..19100a60 100644 --- a/SUUpdateDriver.h +++ b/SUUpdateDriver.h @@ -21,11 +21,13 @@ extern NSString * const SUUpdateDriverFinishedNotification; NSURL *appcastURL; BOOL finished; + BOOL isInterruptible; } - initWithUpdater:(SUUpdater *)updater; - (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host; - (void)abortUpdate; +- (BOOL)isInterruptible; - (BOOL)finished; @end diff --git a/SUUpdateDriver.m b/SUUpdateDriver.m index d98282a9..c844031b 100644 --- a/SUUpdateDriver.m +++ b/SUUpdateDriver.m @@ -33,6 +33,8 @@ NSString * const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished"; [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdateDriverFinishedNotification object:self]; } +- (BOOL)isInterruptible { return isInterruptible; } + - (BOOL)finished { return finished; } - (void)dealloc diff --git a/SUUpdater.m b/SUUpdater.m index 7d426118..6858de18 100644 --- a/SUUpdater.m +++ b/SUUpdater.m @@ -288,6 +288,9 @@ static NSString * const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefault - (IBAction)checkForUpdates: (id)sender { + if (driver && [driver isInterruptible]) + [driver abortUpdate]; + [self checkForUpdatesWithDriver:[[[SUUserInitiatedUpdateDriver alloc] initWithUpdater:self] autorelease]]; }