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.
This commit is contained in:
Andy Matuschak committed 2008-05-30 22:27:00 -07:00
1 parent 43ee59357d
commit 49cfd57682
1 file changed
+16 -4
+16 -4
View File
@@ -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.