mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Removed the checkInterval IV and factored out its assignment to a checkInterval method in SUUpdater. Now when future updates are scheduled after an initial one exits, they'll use the current interval.
This commit is contained in:
1 parent
57b5a17a0a
commit
ebb1f01735
2 files changed
+19
-14
No files matched your search
@@ -12,7 +12,6 @@
|
||||
@class SUUpdateDriver;
|
||||
@interface SUUpdater : NSObject {
|
||||
NSTimer *checkTimer;
|
||||
NSTimeInterval checkInterval;
|
||||
SUUpdateDriver *driver;
|
||||
|
||||
NSBundle *hostBundle;
|
||||
|
||||
+19
-13
@@ -14,6 +14,7 @@
|
||||
- (NSArray *)feedParameters;
|
||||
- (BOOL)automaticallyUpdates;
|
||||
- (BOOL)shouldScheduleUpdateCheck;
|
||||
- (NSTimeInterval)checkInterval;
|
||||
@end
|
||||
|
||||
@implementation SUUpdater
|
||||
@@ -82,16 +83,7 @@ static SUUpdater *sharedUpdater = nil;
|
||||
}
|
||||
|
||||
- (void)beginUpdateCycle
|
||||
{
|
||||
// Find the stored check interval. User defaults override Info.plist.
|
||||
if ([[SUUserDefaults standardUserDefaults] objectForKey:SUScheduledCheckIntervalKey])
|
||||
checkInterval = [[[SUUserDefaults standardUserDefaults] objectForKey:SUScheduledCheckIntervalKey] doubleValue];
|
||||
else if ([hostBundle objectForInfoDictionaryKey:SUScheduledCheckIntervalKey])
|
||||
checkInterval = [[hostBundle objectForInfoDictionaryKey:SUScheduledCheckIntervalKey] doubleValue];
|
||||
|
||||
if (checkInterval < SU_MIN_CHECK_INTERVAL) // This can also mean one that isn't set.
|
||||
checkInterval = SU_DEFAULT_CHECK_INTERVAL;
|
||||
|
||||
{
|
||||
// How long has it been since last we checked for an update?
|
||||
NSDate *lastCheckDate = [[SUUserDefaults standardUserDefaults] objectForKey:SULastCheckTimeKey];
|
||||
if (!lastCheckDate) { lastCheckDate = [NSDate distantPast]; }
|
||||
@@ -99,8 +91,8 @@ static SUUpdater *sharedUpdater = nil;
|
||||
|
||||
// Now we want to figure out how long until we check again.
|
||||
NSTimeInterval delayUntilCheck;
|
||||
if (intervalSinceCheck < checkInterval)
|
||||
delayUntilCheck = (checkInterval - intervalSinceCheck); // It hasn't been long enough.
|
||||
if (intervalSinceCheck < [self checkInterval])
|
||||
delayUntilCheck = ([self checkInterval] - intervalSinceCheck); // It hasn't been long enough.
|
||||
else
|
||||
delayUntilCheck = 0; // We're overdue! Run one now.
|
||||
|
||||
@@ -143,7 +135,7 @@ static SUUpdater *sharedUpdater = nil;
|
||||
[driver removeObserver:self forKeyPath:@"finished"];
|
||||
[driver release]; driver = nil;
|
||||
if ([self shouldScheduleUpdateCheck])
|
||||
checkTimer = [NSTimer scheduledTimerWithTimeInterval:checkInterval target:self selector:@selector(checkForUpdatesInBackground) userInfo:nil repeats:NO];
|
||||
checkTimer = [NSTimer scheduledTimerWithTimeInterval:[self checkInterval] target:self selector:@selector(checkForUpdatesInBackground) userInfo:nil repeats:NO];
|
||||
}
|
||||
|
||||
- (BOOL)shouldScheduleUpdateCheck
|
||||
@@ -188,6 +180,20 @@ static SUUpdater *sharedUpdater = nil;
|
||||
return parameters;
|
||||
}
|
||||
|
||||
- (NSTimeInterval)checkInterval
|
||||
{
|
||||
NSTimeInterval checkInterval = 0;
|
||||
// Find the stored check interval. User defaults override Info.plist.
|
||||
if ([[SUUserDefaults standardUserDefaults] objectForKey:SUScheduledCheckIntervalKey])
|
||||
checkInterval = [[[SUUserDefaults standardUserDefaults] objectForKey:SUScheduledCheckIntervalKey] doubleValue];
|
||||
else if ([hostBundle objectForInfoDictionaryKey:SUScheduledCheckIntervalKey])
|
||||
checkInterval = [[hostBundle objectForInfoDictionaryKey:SUScheduledCheckIntervalKey] doubleValue];
|
||||
|
||||
if (checkInterval < SU_MIN_CHECK_INTERVAL) // This can also mean one that isn't set.
|
||||
checkInterval = SU_DEFAULT_CHECK_INTERVAL;
|
||||
return checkInterval;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[hostBundle release];
|
||||
|
||||
Reference in new issue
Block a user