mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Fixes 258529 and 257967
Added backwards compatibility support for Sparkle 1.1's behavior of disabling automatic updates when the check interval was 0. Sparkle will now properly reset the update cycle when setAutomaticallyChecksForUpdates or setUpdateCheckInterval is called for non-.app bundles.
This commit is contained in:
1 parent
ec7f38d157
commit
c21e1aba35
1 file changed
+26
-8
+26
-8
@@ -151,9 +151,11 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv
|
||||
NSTimeInterval intervalSinceCheck = [[NSDate date] timeIntervalSinceDate:lastCheckDate];
|
||||
|
||||
// Now we want to figure out how long until we check again.
|
||||
NSTimeInterval delayUntilCheck;
|
||||
if (intervalSinceCheck < [self updateCheckInterval])
|
||||
delayUntilCheck = ([self updateCheckInterval] - intervalSinceCheck); // It hasn't been long enough.
|
||||
NSTimeInterval delayUntilCheck, updateCheckInterval = [self updateCheckInterval];
|
||||
if (updateCheckInterval < SU_MIN_CHECK_INTERVAL)
|
||||
updateCheckInterval = SU_MIN_CHECK_INTERVAL;
|
||||
if (intervalSinceCheck < updateCheckInterval)
|
||||
delayUntilCheck = (updateCheckInterval - intervalSinceCheck); // It hasn't been long enough.
|
||||
else
|
||||
delayUntilCheck = 0; // We're overdue! Run one now.
|
||||
checkTimer = [NSTimer scheduledTimerWithTimeInterval:delayUntilCheck target:self selector:@selector(checkForUpdatesInBackground) userInfo:nil repeats:NO];
|
||||
@@ -229,10 +231,20 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv
|
||||
- (void)setAutomaticallyChecksForUpdates:(BOOL)automaticallyCheckForUpdates
|
||||
{
|
||||
[host setBool:automaticallyCheckForUpdates forUserDefaultsKey:SUEnableAutomaticChecksKey];
|
||||
// Hack to support backwards compatibility with older Sparkle versions, which supported
|
||||
// disabling updates by setting the check interval to 0.
|
||||
if (automaticallyCheckForUpdates && [self updateCheckInterval] == 0)
|
||||
[self setUpdateCheckInterval:SU_DEFAULT_CHECK_INTERVAL];
|
||||
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil];
|
||||
// Provide a small delay in case multiple preferences are being updated simultaneously.
|
||||
[self performSelector:@selector(resetUpdateCycle) withObject:nil afterDelay:1];
|
||||
}
|
||||
|
||||
- (BOOL)automaticallyChecksForUpdates
|
||||
{
|
||||
// Don't automatically update when the check interval is 0, to be compatible with 1.1 settings.
|
||||
if ([self updateCheckInterval] == 0)
|
||||
return NO;
|
||||
return [host boolForKey:SUEnableAutomaticChecksKey];
|
||||
}
|
||||
|
||||
@@ -320,16 +332,22 @@ static NSString *SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaultsObserv
|
||||
- (void)setUpdateCheckInterval:(NSTimeInterval)updateCheckInterval
|
||||
{
|
||||
[host setObject:[NSNumber numberWithDouble:updateCheckInterval] forUserDefaultsKey:SUScheduledCheckIntervalKey];
|
||||
if (updateCheckInterval == 0) // For compatibility with 1.1's settings.
|
||||
[self setAutomaticallyChecksForUpdates:NO];
|
||||
[[self class] cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetUpdateCycle) object:nil];
|
||||
|
||||
// Provide a small delay in case multiple preferences are being updated simultaneously.
|
||||
[self performSelector:@selector(resetUpdateCycle) withObject:nil afterDelay:1];
|
||||
}
|
||||
|
||||
- (NSTimeInterval)updateCheckInterval
|
||||
{
|
||||
// Find the stored check interval. User defaults override Info.plist.
|
||||
NSTimeInterval checkInterval = [[host objectForKey:SUScheduledCheckIntervalKey] doubleValue];
|
||||
|
||||
if (checkInterval < SU_MIN_CHECK_INTERVAL) // This can also mean one that isn't set.
|
||||
checkInterval = SU_DEFAULT_CHECK_INTERVAL;
|
||||
return checkInterval;
|
||||
NSNumber *intervalValue = [host objectForKey:SUScheduledCheckIntervalKey];
|
||||
if (intervalValue)
|
||||
return [intervalValue doubleValue];
|
||||
else
|
||||
return SU_DEFAULT_CHECK_INTERVAL;
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
|
||||
Reference in new issue
Block a user