mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-22 04:30:47 +00:00
Use impatient update interval for non-automatic mode too
If we're resuming an update that wasn't user initiated and can be installed silently we should check the impatient update interval.
This commit is contained in:
1 parent
b91ab180d5
commit
67a65b7dba
3 files changed
+19
-10
No files matched your search
Vendored
+1
-2
@@ -39,8 +39,7 @@ SPU_OBJC_DIRECT_MEMBERS @interface SPUUpdateDriver : NSObject
|
||||
|
||||
- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle updater:(id)updater userDriver:(nullable id <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SPUUpdaterDelegate>)updaterDelegate userInitiated:(BOOL)userInitiated installMode:(SPUUpdateDriverInstallMode)installMode;
|
||||
|
||||
// Only meaningful for a driver constructed with SPUUpdateDriverInstallModeAutomatic.
|
||||
// Must be set (along with impatientUpdateCheckInterval) before starting a check.
|
||||
// Must be set (along with impatientUpdateCheckInterval) before starting a scheduled (automatic or UI) check.
|
||||
@property (nonatomic, copy) NSDate *lastImpatientCheckedDate;
|
||||
@property (nonatomic) NSTimeInterval impatientUpdateCheckInterval;
|
||||
|
||||
|
||||
Vendored
+10
@@ -300,6 +300,16 @@ static BOOL SPUUpdateRequiresUserAttentionBeforeDownloading(SUAppcastItem *updat
|
||||
}
|
||||
|
||||
if (_installMode == SPUUpdateDriverInstallModeShowingUI) {
|
||||
// If we are resuming an update that can be installed silently which was not user initiated, defer showing update until
|
||||
// impatient interval has elapsed.
|
||||
if (resumingExistingUpdate && _startedResumingInstallingUpdate && !_userInitiated && !updateItem.criticalUpdate && !SPUUpdateRequiresUserAttentionBeforeDownloading(updateItem)) {
|
||||
NSTimeInterval intervalSinceImpatientDate = [[NSDate date] timeIntervalSinceDate:_lastImpatientCheckedDate];
|
||||
if (intervalSinceImpatientDate < _impatientUpdateCheckInterval) {
|
||||
[self finishWithError:nil];
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
[self presentUpdateFoundWithAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem];
|
||||
return;
|
||||
}
|
||||
|
||||
Vendored
+8
-8
@@ -594,16 +594,16 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
|
||||
|
||||
SPUUpdateDriver *updateDriver = [[SPUUpdateDriver alloc] initWithHost:_host applicationBundle:_applicationBundle updater:self userDriver:_userDriver updaterDelegate:delegate userInitiated:NO installMode:installMode];
|
||||
|
||||
if (installMode == SPUUpdateDriverInstallModeAutomatic) {
|
||||
if ([_updateLastImpatientCheckedDate timeIntervalSinceNow] > 0) {
|
||||
// Last impatient checked date is bogus (in the future), reset it
|
||||
_updateLastImpatientCheckedDate = [NSDate date];
|
||||
}
|
||||
|
||||
updateDriver.impatientUpdateCheckInterval = _updaterSettings.impatientUpdateCheckInterval;
|
||||
updateDriver.lastImpatientCheckedDate = _updateLastImpatientCheckedDate;
|
||||
if ([_updateLastImpatientCheckedDate timeIntervalSinceNow] > 0) {
|
||||
// Last impatient checked date is bogus (in the future), reset it
|
||||
_updateLastImpatientCheckedDate = [NSDate date];
|
||||
}
|
||||
|
||||
// This may be used even if installMode is not SPUUpdateDriverInstallModeAutomatic
|
||||
// For example, an update that has already started installing prior to this session.
|
||||
updateDriver.impatientUpdateCheckInterval = _updaterSettings.impatientUpdateCheckInterval;
|
||||
updateDriver.lastImpatientCheckedDate = _updateLastImpatientCheckedDate;
|
||||
|
||||
[self checkForUpdatesWithDriver:updateDriver updateCheck:SPUUpdateCheckUpdatesInBackground];
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user