From 49cfd576824bdce259bb277acb477e117073744c Mon Sep 17 00:00:00 2001 From: Andy Matuschak Date: Fri, 30 May 2008 22:27:00 -0700 Subject: [PATCH] Fixed a confounding bug that somehow slipped in: when an update check was aborted, I was calling -automaticallyUpdates to determine whether I should reschedule another update check. This is dumb, because that method denotes whether the user's chosen to automatically update to available new versions. Now it does the right thing. --- SUUpdater.m | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/SUUpdater.m b/SUUpdater.m index fdf7da7c..f3fd34d7 100644 --- a/SUUpdater.m +++ b/SUUpdater.m @@ -13,6 +13,7 @@ - (void)beginUpdateCycle; - (NSArray *)feedParameters; - (BOOL)automaticallyUpdates; +- (BOOL)shouldScheduleUpdateCheck; @end @implementation SUUpdater @@ -68,9 +69,7 @@ static SUUpdater *sharedUpdater = nil; } // We check if the user's said they want updates, or they haven't said anything, and the default is set to checking. - if ([[SUUserDefaults standardUserDefaults] boolForKey:SUEnableAutomaticChecksKey] == YES || - ([[SUUserDefaults standardUserDefaults] objectForKey:SUEnableAutomaticChecksKey] == nil && - [[hostBundle objectForInfoDictionaryKey:SUEnableAutomaticChecksKey] boolValue] == YES)) + if ([self shouldScheduleUpdateCheck]) [self beginUpdateCycle]; } @@ -143,10 +142,23 @@ static SUUpdater *sharedUpdater = nil; if (object != driver) { return; } [driver removeObserver:self forKeyPath:@"finished"]; [driver release]; driver = nil; - if ([self automaticallyUpdates]) + if ([self shouldScheduleUpdateCheck]) checkTimer = [NSTimer scheduledTimerWithTimeInterval:checkInterval target:self selector:@selector(checkForUpdatesInBackground) userInfo:nil repeats:NO]; } +- (BOOL)shouldScheduleUpdateCheck +{ + // Breaking this down for readability: + // If the user says he wants automatic update checks, let's do it. + if ([[SUUserDefaults standardUserDefaults] boolForKey:SUEnableAutomaticChecksKey] == YES) + return YES; + // If the user hasn't said anything, but the developer says we should do it, let's do it. + if ([[SUUserDefaults standardUserDefaults] objectForKey:SUEnableAutomaticChecksKey] == nil && + [[hostBundle objectForInfoDictionaryKey:SUEnableAutomaticChecksKey] boolValue] == YES) + return YES; + return NO; // Otherwise, don't bothe.r +} + - (BOOL)automaticallyUpdates { // If the SUAllowsAutomaticUpdatesKey exists and is set to NO, return NO.