Handle informational only updates from the automatic update driver

The automatic update driver defers the informational only update & aborts, allowing a scheduled UI driver to resume it. The automatic update driver aborts before the point an update would normally be downloaded.
This commit is contained in:
Zorg committed 2017-01-01 21:22:02 -05:00
1 parent 27a24a5413
commit 0bb3ab51b3
6 files changed
+32 -5

No files matched your search

+7 -2
View File
@@ -84,7 +84,12 @@
{
self.updateItem = updateItem;
[self.coreDriver downloadUpdateFromAppcastItem:updateItem];
if (updateItem.isInformationOnlyUpdate) {
[self.coreDriver deferInformationalUpdate:updateItem];
[self abortUpdate];
} else {
[self.coreDriver downloadUpdateFromAppcastItem:updateItem];
}
}
- (void)installerDidFinishPreparationAndWillInstallImmediately:(BOOL)willInstallImmediately silently:(BOOL)willInstallSilently
@@ -126,7 +131,7 @@
- (void)abortUpdateWithError:(NSError *)error
{
BOOL showNextUpdateImmediately = (error == nil || error.code == SUInstallationAuthorizeLaterError) && (!self.willInstallSilently || self.updateItem.isCriticalUpdate);
BOOL showNextUpdateImmediately = (error == nil || error.code == SUInstallationAuthorizeLaterError) && (!self.willInstallSilently || self.updateItem.isCriticalUpdate || self.updateItem.isInformationOnlyUpdate);
[self.coreDriver abortUpdateAndShowNextUpdateImmediately:showNextUpdateImmediately error:error];
}
+2
View File
@@ -63,6 +63,8 @@ NS_ASSUME_NONNULL_BEGIN
- (void)downloadUpdateFromAppcastItem:(SUAppcastItem *)updateItem;
- (void)deferInformationalUpdate:(SUAppcastItem *)updateItem;
- (void)extractDownloadedUpdate;
- (void)clearDownloadedUpdate;
+6
View File
@@ -203,6 +203,11 @@
[self extractUpdate:downloadedUpdate];
}
- (void)deferInformationalUpdate:(SUAppcastItem *)updateItem
{
self.downloadedUpdate = [[SPUDownloadedUpdate alloc] initWithAppcastItem:updateItem];
}
- (void)extractDownloadedUpdate
{
assert(self.downloadedUpdate != nil);
@@ -342,6 +347,7 @@
[self.downloadDriver cleanup];
SPUDownloadedUpdate *downloadedUpdate = (error == nil || error.code == SUInstallationAuthorizeLaterError) ? self.downloadedUpdate : nil;
[self.basicDriver abortUpdateAndShowNextUpdateImmediately:shouldShowUpdateImmediately downloadedUpdate:downloadedUpdate error:error];
}
+7 -2
View File
@@ -16,9 +16,14 @@ NS_ASSUME_NONNULL_BEGIN
- (instancetype)initWithAppcastItem:(SUAppcastItem *)updateItem downloadName:(NSString *)downloadName temporaryDirectory:(NSString *)temporaryDirectory;
// For information only updates
- (instancetype)initWithAppcastItem:(SUAppcastItem *)updateItem;
@property (nonatomic, readonly) SUAppcastItem *updateItem;
@property (nonatomic, copy, readonly) NSString *downloadName;
@property (nonatomic, copy, readonly) NSString *temporaryDirectory;
// These are nil when the update item is just informational and no download is linked
@property (nonatomic, copy, nullable, readonly) NSString *downloadName;
@property (nonatomic, copy, nullable, readonly) NSString *temporaryDirectory;
@end
+9
View File
@@ -29,4 +29,13 @@
return self;
}
- (instancetype)initWithAppcastItem:(SUAppcastItem *)updateItem
{
self = [super init];
if (self != nil) {
_updateItem = updateItem;
}
return self;
}
@end
+1 -1
View File
@@ -797,7 +797,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification
// Proceed as normal if there's no resumable updates
completionHandler(regularCheckInterval);
} else {
if (!installationInfo.canSilentlyInstall || [installationInfo.appcastItem isCriticalUpdate]) {
if (!installationInfo.canSilentlyInstall || [installationInfo.appcastItem isCriticalUpdate] || [installationInfo.appcastItem isInformationOnlyUpdate]) {
completionHandler(MIN(regularCheckInterval, SUImpatientUpdateCheckInterval));
} else {
completionHandler(MAX(regularCheckInterval, SUImpatientUpdateCheckInterval));