From f5d3cb45004714d18a25b267e7cc5bf0b2930b6d Mon Sep 17 00:00:00 2001 From: Marcus Ososbase Date: Sun, 26 Feb 2017 00:11:30 -0500 Subject: [PATCH] Allow check for updates even though download not possible --- Sparkle/SUBasicUpdateDriver.m | 16 +++++++++++++++- Sparkle/SUUpdater.m | 14 +------------- Sparkle/SUUpdaterPrivate.h | 2 ++ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 42d6e185..7189476d 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -212,7 +212,21 @@ [[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterDidFindValidUpdateNotification object:self.updater userInfo:@{ SUUpdaterAppcastItemNotificationKey: self.updateItem }]; - [self downloadUpdate]; + + + if (![updater automaticallyDownloadsUpdates]) + { + // TB: App is in a non writable directory + NSError *error = + [NSError errorWithDomain:SUSparkleErrorDomain code:SUHostDirectoryNotWritable + userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"Host directory is not writable", nil)}]; + + [self abortUpdateWithError:error]; + } + else + { + [self downloadUpdate]; + } } - (void)didNotFindUpdate diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index 2cf22912..6d0d20ce 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -284,22 +284,10 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults - (void)checkForUpdatesInBackground { // Do not use reachability for a preflight check. This can be deceptive and a bad idea. Apple does not recommend doing it. - BOOL canAutomaticallyDownloadUpdates = [self automaticallyDownloadsUpdates]; - if (!canAutomaticallyDownloadUpdates) - { - // TB: App is in a non writable directory - if ([self.delegate respondsToSelector:@selector(updater:didAbortWithError:)]) { - NSError *error = - [NSError errorWithDomain:SUSparkleErrorDomain code:SUHostDirectoryNotWritable - userInfo:@{NSLocalizedDescriptionKey: SULocalizedString(@"Host directory is not writable", nil)}]; - [self.delegate updater:self didAbortWithError:error]; - } - return; - } SUUpdateDriver *theUpdateDriver; - if (canAutomaticallyDownloadUpdates || [self.delegate suppressSparkleUI]) + if ([self.delegate suppressSparkleUI]) { theUpdateDriver = [[SUAutomaticUpdateDriver alloc] initWithUpdater:self]; } diff --git a/Sparkle/SUUpdaterPrivate.h b/Sparkle/SUUpdaterPrivate.h index 3e7dad26..0fbf5fd8 100644 --- a/Sparkle/SUUpdaterPrivate.h +++ b/Sparkle/SUUpdaterPrivate.h @@ -20,4 +20,6 @@ @property (strong, readonly) NSBundle *sparkleBundle; +@property BOOL automaticallyDownloadsUpdates; + @end