diff --git a/Sparkle/SUAutomaticUpdateDriver.m b/Sparkle/SUAutomaticUpdateDriver.m index f6d23b04..6abb1294 100644 --- a/Sparkle/SUAutomaticUpdateDriver.m +++ b/Sparkle/SUAutomaticUpdateDriver.m @@ -62,7 +62,7 @@ static const NSTimeInterval SUAutomaticUpdatePromptImpatienceTimer = 60 * 60 * 2 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActive:) name:NSApplicationDidBecomeActiveNotification object:NSApp]; } -- (void)unarchiverDidFinish +- (void)unarchiverDidFinish:(id)__unused ua { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationWillTerminate:) name:NSApplicationWillTerminateNotification object:nil]; [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(systemWillPowerOff:) name:NSWorkspaceWillPowerOffNotification object:nil]; diff --git a/Sparkle/SUBasicUpdateDriver.h b/Sparkle/SUBasicUpdateDriver.h index 0e61f5f3..97dc34e8 100644 --- a/Sparkle/SUBasicUpdateDriver.h +++ b/Sparkle/SUBasicUpdateDriver.h @@ -40,6 +40,10 @@ - (void)extractUpdate; - (void)failedToApplyDeltaUpdate; +// Needed to preserve compatibility to subclasses, even though our unarchiver code uses blocks now +- (void)unarchiver:(id)ua extractedProgress:(double)progress; +- (void)unarchiverDidFinish:(id)ua; + - (void)installWithToolAndRelaunch:(BOOL)relaunch; - (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)showUI; - (void)installerForHost:(SUHost *)host failedWithError:(NSError *)error; diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 3b568e73..4e6d5d1f 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -334,17 +334,18 @@ if (!success) { NSError *reason = [NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{NSLocalizedDescriptionKey: @"Failed to extract update."}]; - [self unarchiverDidFail:reason]; + [self unarchiverDidFailWithError:reason]; } else { [unarchiver unarchiveWithCompletionBlock:^(NSError *err){ if (err) { - [self unarchiverDidFail:err]; + [self unarchiverDidFailWithError:err]; return; } - - // This will call any of the subclass' implementation of -unarchiverDidFinish first - [self unarchiverDidFinish]; - } progressBlock:nil]; + + [self unarchiverDidFinish:nil]; + } progressBlock:^(double progress) { + [self unarchiver:nil extractedProgress:progress]; + }]; } } @@ -357,14 +358,20 @@ [self downloadUpdate]; } -- (void)unarchiverDidFinish +// By default does nothing, can be overridden +- (void)unarchiver:(id)__unused ua extractedProgress:(double)__unused progress +{ +} + +// Note this method can be overridden (and is) +- (void)unarchiverDidFinish:(id)__unused ua { assert(self.updateItem); - + [self installWithToolAndRelaunch:YES]; } -- (void)unarchiverDidFail:(NSError *)err +- (void)unarchiverDidFailWithError:(NSError *)err { // No longer needed self.updateValidator = nil; @@ -373,7 +380,7 @@ [self failedToApplyDeltaUpdate]; return; } - + [self abortUpdateWithError:err]; } diff --git a/Sparkle/SUUIBasedUpdateDriver.m b/Sparkle/SUUIBasedUpdateDriver.m index 58da9bab..caa3959a 100644 --- a/Sparkle/SUUIBasedUpdateDriver.m +++ b/Sparkle/SUUIBasedUpdateDriver.m @@ -216,7 +216,7 @@ [super extractUpdate]; } -- (void)unarchiver:(SUUnarchiver *)__unused ua extractedProgress:(double)progress +- (void)unarchiver:(id)__unused ua extractedProgress:(double)progress { // We do this here instead of in extractUpdate so that we only have a determinate progress bar for archives with progress. if ([self.statusController maxProgressValue] == 0.0) { @@ -225,7 +225,7 @@ [self.statusController setProgressValue:progress]; } -- (void)unarchiverDidFinish +- (void)unarchiverDidFinish:(id)__unused ua { if (self.automaticallyInstallUpdates) { [self installWithToolAndRelaunch:YES];