diff --git a/Sparkle/SUAutomaticUpdateDriver.m b/Sparkle/SUAutomaticUpdateDriver.m index 9ae7eb1e..46817b1c 100644 --- a/Sparkle/SUAutomaticUpdateDriver.m +++ b/Sparkle/SUAutomaticUpdateDriver.m @@ -49,6 +49,12 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 - (void)showUpdateAlert { self.interruptible = NO; + [self invalidateShowUpdateAlertTimer]; + + if (self.alert) { + [self.alert close]; + } + self.alert = [[SUAutomaticUpdateAlert alloc] initWithAppcastItem:self.updateItem host:self.host completionBlock:^(SUAutomaticInstallationChoice choice) { [self automaticUpdateAlertFinishedWithChoice:choice]; }]; @@ -107,6 +113,14 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 } } +-(BOOL)resumeUpdateInteractively { + if ([self isInterruptible]) { + [self showUpdateAlert]; + return YES; + } + return NO; +} + - (void)stopUpdatingOnTermination { if (self.willUpdateOnTermination) @@ -140,6 +154,8 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 - (void)abortUpdate { + [self.alert close]; + self.isTerminating = NO; [self stopUpdatingOnTermination]; [self invalidateShowUpdateAlertTimer]; @@ -154,6 +170,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 - (void)automaticUpdateAlertFinishedWithChoice:(SUAutomaticInstallationChoice)choice { + self.alert = nil; switch (choice) { case SUInstallNowChoice: diff --git a/Sparkle/SUUpdateDriver.h b/Sparkle/SUUpdateDriver.h index 7e132aa1..ab03781d 100644 --- a/Sparkle/SUUpdateDriver.h +++ b/Sparkle/SUUpdateDriver.h @@ -26,7 +26,8 @@ extern NSString *const SUUpdateDriverFinishedNotification; - (instancetype)initWithUpdater:(id)updater; - (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)host; - (void)abortUpdate; - +/** If there is an update waiting to be installed, show UI indicating so. Return NO otherwise (e.g. if it's not supported). */ +- (BOOL)resumeUpdateInteractively; - (void)showAlert:(NSAlert *)alert; @property (getter=isInterruptible, readonly) BOOL interruptible; diff --git a/Sparkle/SUUpdateDriver.m b/Sparkle/SUUpdateDriver.m index 0aed1dfe..f83d2355 100644 --- a/Sparkle/SUUpdateDriver.m +++ b/Sparkle/SUUpdateDriver.m @@ -52,6 +52,9 @@ NSString *const SUUpdateDriverFinishedNotification = @"SUUpdateDriverFinished"; [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdateDriverFinishedNotification object:self]; } +-(BOOL)resumeUpdateInteractively { + return NO; +} - (void)showAlert:(NSAlert *)alert { // Only UI-based subclass shows the actual alert diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index bd2e5a2b..7794db19 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -291,6 +291,9 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults - (IBAction)checkForUpdates:(id)__unused sender { if (self.driver && [self.driver isInterruptible]) { + if ([self.driver resumeUpdateInteractively]) { + return; + } [self.driver abortUpdate]; } @@ -305,6 +308,9 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults - (void)installUpdatesIfAvailable { if (self.driver && [self.driver isInterruptible]) { + if ([self.driver resumeUpdateInteractively]) { + return; + } [self.driver abortUpdate]; }