Remove passing around preventsAutoupdate flag

Also improve user driver documentation slightly.
This commit is contained in:
Zorg committed 2021-05-31 11:57:33 -07:00
1 parent 5287453cfd
commit 1aadf1b351
14 files changed
+27 -36

No files matched your search

+3 -3
View File
@@ -80,12 +80,12 @@
SULog(SULogLevelError, @"Error: resumeDownloadedUpdate:completion: called on SPUAutomaticUpdateDriver");
}
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem *)secondaryUpdateItem preventsAutoupdate:(BOOL)preventsAutoupdate
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem *)secondaryUpdateItem
{
self.updateItem = updateItem;
if (updateItem.isInformationOnlyUpdate || preventsAutoupdate) {
[self.coreDriver deferInformationalUpdate:updateItem secondaryUpdate:secondaryUpdateItem preventsAutoupdate:preventsAutoupdate];
if (updateItem.isInformationOnlyUpdate || updateItem.majorUpgrade) {
[self.coreDriver deferInformationalUpdate:updateItem secondaryUpdate:secondaryUpdateItem];
[self abortUpdate];
} else {
[self.coreDriver downloadUpdateFromAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem inBackground:YES];
+1 -1
View File
@@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
@protocol SPUBasicUpdateDriverDelegate <NSObject>
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)appcastItem secondaryAppcastItem:(SUAppcastItem *)secondaryAppcastItem preventsAutoupdate:(BOOL)preventsAutoupdate systemDomain:(NSNumber * _Nullable)systemDomain;
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)appcastItem secondaryAppcastItem:(SUAppcastItem *)secondaryAppcastItem systemDomain:(NSNumber * _Nullable)systemDomain;
- (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error;
+6 -5
View File
@@ -90,7 +90,8 @@
[self notifyFinishLoadingAppcast];
SUAppcastItem *nonNullUpdateItem = updateItem;
[self notifyFoundValidUpdateWithAppcastItem:nonNullUpdateItem secondaryAppcastItem:secondaryUpdateItem preventsAutoupdate:NO systemDomain:systemDomain];
#warning please check this
[self notifyFoundValidUpdateWithAppcastItem:nonNullUpdateItem secondaryAppcastItem:secondaryUpdateItem systemDomain:systemDomain];
}
}
@@ -139,7 +140,7 @@
}
}
- (void)notifyFoundValidUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem *)secondaryUpdateItem preventsAutoupdate:(BOOL)preventsAutoupdate systemDomain:(NSNumber * _Nullable)systemDomain
- (void)notifyFoundValidUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem *)secondaryUpdateItem systemDomain:(NSNumber * _Nullable)systemDomain
{
if (!self.aborted) {
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification
@@ -150,13 +151,13 @@
[self.updaterDelegate updater:self.updater didFindValidUpdate:updateItem];
}
[self.delegate basicDriverDidFindUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem preventsAutoupdate:preventsAutoupdate systemDomain:systemDomain];
[self.delegate basicDriverDidFindUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem systemDomain:systemDomain];
}
}
- (void)didFindValidUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem *)secondaryAppcastItem preventsAutoupdate:(BOOL)preventsAutoupdate
- (void)didFindValidUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem *)secondaryAppcastItem
{
[self notifyFoundValidUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryAppcastItem preventsAutoupdate:preventsAutoupdate systemDomain:nil];
[self notifyFoundValidUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryAppcastItem systemDomain:nil];
}
- (void)didNotFindUpdateWithLatestAppcastItem:(nullable SUAppcastItem *)latestAppcastItem hostToLatestAppcastItemComparisonResult:(NSComparisonResult)hostToLatestAppcastItemComparisonResult
+2 -2
View File
@@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
@protocol SPUCoreBasedUpdateDriverDelegate <NSObject>
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem *)secondaryAppcastItem preventsAutoupdate:(BOOL)preventsAutoupdate;
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem *)secondaryAppcastItem;
- (void)installerDidFinishPreparationAndWillInstallImmediately:(BOOL)willInstallImmediately silently:(BOOL)willInstallSilently;
@@ -63,7 +63,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)downloadUpdateFromAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem * _Nullable)secondaryUpdateItem inBackground:(BOOL)background;
- (void)deferInformationalUpdate:(SUAppcastItem *)updateItem secondaryUpdate:(SUAppcastItem *)secondaryUpdateItem preventsAutoupdate:(BOOL)preventsAutoupdate;
- (void)deferInformationalUpdate:(SUAppcastItem *)updateItem secondaryUpdate:(SUAppcastItem *)secondaryUpdateItem;
- (void)extractDownloadedUpdate;
+6 -6
View File
@@ -149,7 +149,7 @@
}
}
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem *)secondaryUpdateItem preventsAutoupdate:(BOOL)preventsAutoupdate systemDomain:(NSNumber * _Nullable)systemDomain
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem *)secondaryUpdateItem systemDomain:(NSNumber * _Nullable)systemDomain
{
self.updateItem = updateItem;
self.secondaryUpdateItem = secondaryUpdateItem;
@@ -157,18 +157,18 @@
if (self.resumingInstallingUpdate) {
assert(systemDomain != nil);
[self.installerDriver resumeInstallingUpdateWithUpdateItem:updateItem systemDomain:systemDomain.boolValue];
[self.delegate basicDriverDidFindUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem preventsAutoupdate:preventsAutoupdate];
[self.delegate basicDriverDidFindUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem];
} else {
if (!self.preventsInstallerInteraction) {
// Simple case - delegate allows interaction, so we should continue along
[self.delegate basicDriverDidFindUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem preventsAutoupdate:preventsAutoupdate];
[self.delegate basicDriverDidFindUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem];
} else {
// Package type installations will always require installer interaction as long as we don't support running as root
// If it's not a package type installation, we should be okay since we did an auth check before checking for updates above
if (![updateItem.installationType isEqualToString:SPUInstallationTypeApplication]) {
[self.delegate coreDriverIsRequestingAbortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUNotAllowedInteractionError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:@"A new update is available but cannot be installed because interaction has been prevented."] }]];
} else {
[self.delegate basicDriverDidFindUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem preventsAutoupdate:preventsAutoupdate];
[self.delegate basicDriverDidFindUpdateWithAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem];
}
}
}
@@ -225,9 +225,9 @@
[self extractUpdate:downloadedUpdate];
}
- (void)deferInformationalUpdate:(SUAppcastItem *)updateItem secondaryUpdate:(SUAppcastItem *)secondaryUpdateItem preventsAutoupdate:(BOOL)preventsAutoupdate
- (void)deferInformationalUpdate:(SUAppcastItem *)updateItem secondaryUpdate:(SUAppcastItem *)secondaryUpdateItem
{
self.resumableUpdate = [[SPUInformationalUpdate alloc] initWithAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem preventsAutoupdate:preventsAutoupdate];
self.resumableUpdate = [[SPUInformationalUpdate alloc] initWithAppcastItem:updateItem secondaryAppcastItem:secondaryUpdateItem];
}
- (void)extractDownloadedUpdate
-5
View File
@@ -33,9 +33,4 @@
return self;
}
- (BOOL)preventsAutoupdate
{
return NO;
}
@end
+1 -1
View File
@@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface SPUInformationalUpdate : NSObject <SPUResumableUpdate>
- (instancetype)initWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem *)secondaryUpdateItem preventsAutoupdate:(BOOL)preventsAutoupdate;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem *)secondaryUpdateItem;
@end
+1 -3
View File
@@ -17,15 +17,13 @@
// because the property is declared in a protocol
@synthesize updateItem = _updateItem;
@synthesize secondaryUpdateItem = _secondaryUpdateItem;
@synthesize preventsAutoupdate = _preventsAutoupdate;
- (instancetype)initWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem *)secondaryUpdateItem preventsAutoupdate:(BOOL)preventsAutoupdate
- (instancetype)initWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem *)secondaryUpdateItem
{
self = [super init];
if (self != nil) {
_updateItem = updateItem;
_secondaryUpdateItem = secondaryUpdateItem;
_preventsAutoupdate = preventsAutoupdate;
}
return self;
}
+1 -1
View File
@@ -54,7 +54,7 @@
[self.basicDriver resumeUpdate:resumableUpdate completion:completionBlock];
}
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)__unused appcastItem secondaryAppcastItem:(SUAppcastItem *)__unused secondaryAppcastItem preventsAutoupdate:(BOOL)__unused preventsAutoupdate systemDomain:(NSNumber * _Nullable)__unused systemDomain
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)__unused appcastItem secondaryAppcastItem:(SUAppcastItem *)__unused secondaryAppcastItem systemDomain:(NSNumber * _Nullable)__unused systemDomain
{
// Stop as soon as we have an answer
[self abortUpdate];
-1
View File
@@ -16,7 +16,6 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, readonly) SUAppcastItem *updateItem;
@property (nonatomic, readonly, nullable) SUAppcastItem *secondaryUpdateItem;
@property (nonatomic, readonly) BOOL preventsAutoupdate;
@end
+2 -2
View File
@@ -148,7 +148,7 @@
{
// Informational downloads shouldn't be presented as updates to be downloaded
// Neither should items that prevent auto updating
if (!resumableUpdate.updateItem.isInformationOnlyUpdate && !resumableUpdate.preventsAutoupdate) {
if (!resumableUpdate.updateItem.isInformationOnlyUpdate && !resumableUpdate.updateItem.majorUpgrade) {
self.resumingDownloadedUpdate = YES;
}
[self.coreDriver resumeUpdate:resumableUpdate completion:completionBlock];
@@ -161,7 +161,7 @@
}
}
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem *)secondaryUpdateItem preventsAutoupdate:(BOOL)preventsAutoupdate
- (void)basicDriverDidFindUpdateWithAppcastItem:(SUAppcastItem *)updateItem secondaryAppcastItem:(SUAppcastItem *)secondaryUpdateItem
{
if (self.userInitiated) {
[SPUSkippedUpdate clearSkippedUpdateForHost:self.host];
+2 -2
View File
@@ -68,8 +68,8 @@ SU_EXPORT @protocol SPUUserDriver <NSObject>
*
* state.userInitiated indicates if the update was initiated by the user or if it was automatically scheduled in the background.
*
* Additionally, these two properties on the appcastItem may be of importance:
* appcastItem.informationOnlyUpdate indicates if the update is only informational. These updates cannot be installed because they have no download. You can direct the user to the infoURL property of the appcastItem in their web browser.
* Additionally, these properties on the appcastItem are of importance:
* appcastItem.informationOnlyUpdate indicates if the update is only informational. These updates cannot be installed because they have no download. You can direct the user to the infoURL property of the appcastItem in their web browser. Sometimes information only updates are used as a fallback in case a bad update is shipped, so you'll want to support this case.
* appcastItem.majorUpgrade indicates if the update is a major or paid upgrade.
* appcastItem.criticalUpdate indicates if the update is a critical update.
*
+1 -1
View File
@@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)didFailToFetchAppcastWithError:(NSError *)error;
- (void)didFinishLoadingAppcast:(SUAppcast *)appcast;
- (void)didFindValidUpdateWithAppcastItem:(SUAppcastItem *)appcastItem secondaryAppcastItem:(SUAppcastItem *)secondaryAppcastItem preventsAutoupdate:(BOOL)preventsAutoupdate;
- (void)didFindValidUpdateWithAppcastItem:(SUAppcastItem *)appcastItem secondaryAppcastItem:(SUAppcastItem *)secondaryAppcastItem;
- (void)didNotFindUpdateWithLatestAppcastItem:(nullable SUAppcastItem *)latestAppcastItem hostToLatestAppcastItemComparisonResult:(NSComparisonResult)hostToLatestAppcastItemComparisonResult;
@end
+1 -3
View File
@@ -200,9 +200,7 @@
if ([self isItemNewer:finalPrimaryItem]) {
// We found a suitable update
BOOL preventsAutoupdate = finalPrimaryItem.majorUpgrade;
[self.delegate didFindValidUpdateWithAppcastItem:finalPrimaryItem secondaryAppcastItem:finalSecondaryItem preventsAutoupdate:preventsAutoupdate];
[self.delegate didFindValidUpdateWithAppcastItem:finalPrimaryItem secondaryAppcastItem:finalSecondaryItem];
} else {
// Find the latest appcast item even if it fails min/max OS test
// We want to inform the user if an update requires a different OS version