diff --git a/Sparkle/SPUAutomaticUpdateDriver.m b/Sparkle/SPUAutomaticUpdateDriver.m index 8d2ce908..bb497601 100644 --- a/Sparkle/SPUAutomaticUpdateDriver.m +++ b/Sparkle/SPUAutomaticUpdateDriver.m @@ -60,7 +60,7 @@ if (error != nil) { [self abortUpdateWithError:error]; } else { - [self.coreDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:YES includesSkippedUpdates:NO requiresSilentInstall:YES]; + [self.coreDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:YES requiresSilentInstall:YES]; } }]; } diff --git a/Sparkle/SPUBasicUpdateDriver.h b/Sparkle/SPUBasicUpdateDriver.h index dcde2abf..afe99e8d 100644 --- a/Sparkle/SPUBasicUpdateDriver.h +++ b/Sparkle/SPUBasicUpdateDriver.h @@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)prepareCheckForUpdatesWithCompletion:(SPUUpdateDriverCompletion)completionBlock; -- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background includesSkippedUpdates:(BOOL)includesSkippedUpdates; +- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background; - (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)completionBlock; diff --git a/Sparkle/SPUBasicUpdateDriver.m b/Sparkle/SPUBasicUpdateDriver.m index f399a613..1fea0edf 100644 --- a/Sparkle/SPUBasicUpdateDriver.m +++ b/Sparkle/SPUBasicUpdateDriver.m @@ -65,7 +65,7 @@ self.completionBlock = completionBlock; } -- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background includesSkippedUpdates:(BOOL)includesSkippedUpdates +- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background { if ([self.host isRunningOnReadOnlyVolume]) { NSString *hostName = self.host.name; @@ -75,7 +75,7 @@ [self.delegate basicDriverIsRequestingAbortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURunningFromDiskImageError userInfo:@{ NSLocalizedDescriptionKey: [NSString stringWithFormat:SULocalizedString(@"%1$@ can't be updated, because it was opened from a read-only or a temporary location.", nil), hostName], NSLocalizedRecoverySuggestionErrorKey: [NSString stringWithFormat:SULocalizedString(@"Use Finder to copy %1$@ to the Applications folder, relaunch it from there, and try again.", nil), hostName] }]]; } } else { - [self.appcastDriver loadAppcastFromURL:appcastURL userAgent:userAgent httpHeaders:httpHeaders inBackground:background includesSkippedUpdates:includesSkippedUpdates]; + [self.appcastDriver loadAppcastFromURL:appcastURL userAgent:userAgent httpHeaders:httpHeaders inBackground:background]; } } @@ -169,7 +169,7 @@ NSString *recoverySuggestion; NSString *recoveryOption; - if (latestAppcastItem != nil) { // if the appcast was successfully loaded + if (latestAppcastItem != nil) { switch (hostToLatestAppcastItemComparisonResult) { case NSOrderedDescending: // This means the user is a 'newer than latest' version. give a slight hint to the user instead of wrongly claiming this version is identical to the latest feed version. @@ -204,7 +204,8 @@ recoveryOption = @"OK"; } else { - // When no updates are found in the appcast + // When no updates are found in the appcast, or latest appcast item info + // was not provided (i.e, for a background update check) localizedDescription = SULocalizedString(@"Update Error!", nil); recoverySuggestion = SULocalizedString(@"No valid update information could be loaded.", nil); recoveryOption = SULocalizedString(@"Cancel Update", nil); diff --git a/Sparkle/SPUCoreBasedUpdateDriver.h b/Sparkle/SPUCoreBasedUpdateDriver.h index f936e9b0..64f8ffb9 100644 --- a/Sparkle/SPUCoreBasedUpdateDriver.h +++ b/Sparkle/SPUCoreBasedUpdateDriver.h @@ -55,7 +55,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)preflightForUpdatePermissionPreventingInstallerInteraction:(BOOL)preventsInstallerInteraction reply:(void (^)(NSError * _Nullable))reply; -- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background includesSkippedUpdates:(BOOL)includesSkippedUpdates requiresSilentInstall:(BOOL)silentInstall; +- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background requiresSilentInstall:(BOOL)silentInstall; - (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)completionBlock; diff --git a/Sparkle/SPUCoreBasedUpdateDriver.m b/Sparkle/SPUCoreBasedUpdateDriver.m index 3d65c381..551fd2c2 100644 --- a/Sparkle/SPUCoreBasedUpdateDriver.m +++ b/Sparkle/SPUCoreBasedUpdateDriver.m @@ -114,13 +114,13 @@ } } -- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background includesSkippedUpdates:(BOOL)includesSkippedUpdates requiresSilentInstall:(BOOL)silentInstall +- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background requiresSilentInstall:(BOOL)silentInstall { self.userAgent = userAgent; self.httpHeaders = httpHeaders; self.silentInstall = silentInstall; - [self.basicDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:background includesSkippedUpdates:includesSkippedUpdates]; + [self.basicDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:background]; } - (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)completionBlock diff --git a/Sparkle/SPUProbingUpdateDriver.m b/Sparkle/SPUProbingUpdateDriver.m index bb377ef7..71257a36 100644 --- a/Sparkle/SPUProbingUpdateDriver.m +++ b/Sparkle/SPUProbingUpdateDriver.m @@ -39,7 +39,7 @@ [self.basicDriver prepareCheckForUpdatesWithCompletion:completionBlock]; - [self.basicDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:YES includesSkippedUpdates:NO]; + [self.basicDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:YES]; } - (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)completionBlock diff --git a/Sparkle/SPUScheduledUpdateDriver.m b/Sparkle/SPUScheduledUpdateDriver.m index db9641ee..cffe7499 100644 --- a/Sparkle/SPUScheduledUpdateDriver.m +++ b/Sparkle/SPUScheduledUpdateDriver.m @@ -45,7 +45,7 @@ // Don't tell the user about the permission error for scheduled update checks [self abortUpdateWithError:nil]; } else { - [self.uiDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:YES includesSkippedUpdates:NO]; + [self.uiDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:YES]; } }]; } diff --git a/Sparkle/SPUUIBasedUpdateDriver.h b/Sparkle/SPUUIBasedUpdateDriver.h index f49a564a..de4330bd 100644 --- a/Sparkle/SPUUIBasedUpdateDriver.h +++ b/Sparkle/SPUUIBasedUpdateDriver.h @@ -35,7 +35,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)preflightForUpdatePermissionPreventingInstallerInteraction:(BOOL)preventsInstallerInteraction reply:(void (^)(NSError * _Nullable))reply; -- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background includesSkippedUpdates:(BOOL)includesSkippedUpdates; +- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background; - (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)completionBlock; diff --git a/Sparkle/SPUUIBasedUpdateDriver.m b/Sparkle/SPUUIBasedUpdateDriver.m index 16813217..77b5a13d 100644 --- a/Sparkle/SPUUIBasedUpdateDriver.m +++ b/Sparkle/SPUUIBasedUpdateDriver.m @@ -131,9 +131,9 @@ [self.coreDriver preflightForUpdatePermissionPreventingInstallerInteraction:preventsInstallerInteraction reply:reply]; } -- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background includesSkippedUpdates:(BOOL)includesSkippedUpdates +- (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background { - [self.coreDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:background includesSkippedUpdates:includesSkippedUpdates requiresSilentInstall:NO]; + [self.coreDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:background requiresSilentInstall:NO]; } - (void)resumeInstallingUpdateWithCompletion:(SPUUpdateDriverCompletion)completionBlock diff --git a/Sparkle/SPUUserInitiatedUpdateDriver.m b/Sparkle/SPUUserInitiatedUpdateDriver.m index fc793aec..b99d0803 100644 --- a/Sparkle/SPUUserInitiatedUpdateDriver.m +++ b/Sparkle/SPUUserInitiatedUpdateDriver.m @@ -79,7 +79,7 @@ }]; } - [self.uiDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:NO includesSkippedUpdates:YES]; + [self.uiDriver checkForUpdatesAtAppcastURL:appcastURL withUserAgent:userAgent httpHeaders:httpHeaders inBackground:NO]; } } }]; diff --git a/Sparkle/SUAppcastDriver.h b/Sparkle/SUAppcastDriver.h index cc1a426e..cc142d72 100644 --- a/Sparkle/SUAppcastDriver.h +++ b/Sparkle/SUAppcastDriver.h @@ -26,7 +26,7 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)initWithHost:(SUHost *)host updater:(id)updater updaterDelegate:(nullable id )updaterDelegate delegate:(nullable id )delegate; -- (void)loadAppcastFromURL:(NSURL *)appcastURL userAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background includesSkippedUpdates:(BOOL)includesSkippedUpdates; +- (void)loadAppcastFromURL:(NSURL *)appcastURL userAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background; - (void)cleanup:(void (^)(void))completionHandler; diff --git a/Sparkle/SUAppcastDriver.m b/Sparkle/SUAppcastDriver.m index 7d0c359c..f542c241 100644 --- a/Sparkle/SUAppcastDriver.m +++ b/Sparkle/SUAppcastDriver.m @@ -33,7 +33,6 @@ @property (nullable, nonatomic, readonly, weak) id updaterDelegate; @property (nullable, nonatomic, readonly, weak) id delegate; @property (nonatomic) SPUDownloadDriver *downloadDriver; -@property (nonatomic) BOOL includesSkippedUpdates; @end @@ -44,7 +43,6 @@ @synthesize updaterDelegate = _updaterDelegate; @synthesize delegate = _delegate; @synthesize downloadDriver = _downloadDriver; -@synthesize includesSkippedUpdates = _includesSkippedUpdates; - (instancetype)initWithHost:(SUHost *)host updater:(id)updater updaterDelegate:(id )updaterDelegate delegate:(id )delegate { @@ -58,7 +56,7 @@ return self; } -- (void)loadAppcastFromURL:(NSURL *)appcastURL userAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background includesSkippedUpdates:(BOOL)includesSkippedUpdates +- (void)loadAppcastFromURL:(NSURL *)appcastURL userAgent:(NSString *)userAgent httpHeaders:(NSDictionary * _Nullable)httpHeaders inBackground:(BOOL)background { NSMutableDictionary *requestHTTPHeaders = [NSMutableDictionary dictionary]; if (httpHeaders != nil) { @@ -68,8 +66,6 @@ self.downloadDriver = [[SPUDownloadDriver alloc] initWithRequestURL:appcastURL host:self.host userAgent:userAgent httpHeaders:requestHTTPHeaders inBackground:background delegate:self]; - self.includesSkippedUpdates = includesSkippedUpdates; - [self.downloadDriver downloadFile]; } @@ -87,7 +83,7 @@ [self.delegate didFailToFetchAppcastWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUAppcastParseError userInfo:userInfo]]; } else { - [self appcastDidFinishLoading:appcast inBackground:self.downloadDriver.inBackground includesSkippedUpdates:self.includesSkippedUpdates]; + [self appcastDidFinishLoading:appcast inBackground:self.downloadDriver.inBackground]; } } @@ -155,7 +151,7 @@ return [self preferredUpdateForRegularAppcastItem:regularItem secondaryUpdate:secondaryAppcastItem]; } -- (void)appcastDidFinishLoading:(SUAppcast *)loadedAppcast inBackground:(BOOL)background includesSkippedUpdates:(BOOL)includesSkippedUpdates +- (void)appcastDidFinishLoading:(SUAppcast *)loadedAppcast inBackground:(BOOL)background { [self.delegate didFinishLoadingAppcast:loadedAppcast]; @@ -171,7 +167,7 @@ NSNumber *phasedUpdateGroup = background ? @([SUPhasedUpdateGroupInfo updateGroupForHost:self.host]) : nil; - NSString *skippedVersion = !includesSkippedUpdates ? [self.host objectForUserDefaultsKey:SUSkippedVersionKey] : nil; + NSString *skippedVersion = background ? [self.host objectForUserDefaultsKey:SUSkippedVersionKey] : nil; // First filter out min/max OS version and see if there's an update that passes // the minimum autoupdate version. We filter out updates that fail the minimum @@ -203,11 +199,12 @@ } 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 - SUAppcastItem *notFoundPrimaryItem = [self retrieveBestAppcastItemFromAppcast:macOSAppcast versionComparator:applicationVersionComparator secondaryUpdate:nil]; + // We only need to do this if an update is being checked automatically in the background + SUAppcastItem *notFoundPrimaryItem = background ? [self retrieveBestAppcastItemFromAppcast:macOSAppcast versionComparator:applicationVersionComparator secondaryUpdate:nil] : nil; NSComparisonResult hostToLatestAppcastItemComparisonResult = (notFoundPrimaryItem != nil) ? [applicationVersionComparator compareVersion:self.host.version toVersion:notFoundPrimaryItem.versionString] : 0; - SUStandardVersionComparator *standardVersionComparator = [[SUStandardVersionComparator alloc] init]; + SUStandardVersionComparator *standardVersionComparator = (notFoundPrimaryItem != nil) ? [[SUStandardVersionComparator alloc] init] : nil; BOOL passesMinOSVersion = (notFoundPrimaryItem != nil) ? [[self class] isItemMinimumOperatingSystemVersionOK:notFoundPrimaryItem versionComparator:standardVersionComparator] : YES; BOOL passesMaxOSVersion = (notFoundPrimaryItem != nil) ? [[self class] isItemMaximumOperatingSystemVersionOK:notFoundPrimaryItem versionComparator:standardVersionComparator] : YES;