diff --git a/Sparkle/SPUScheduledUpdateDriver.m b/Sparkle/SPUScheduledUpdateDriver.m index ffd503f1..f648b607 100644 --- a/Sparkle/SPUScheduledUpdateDriver.m +++ b/Sparkle/SPUScheduledUpdateDriver.m @@ -18,24 +18,20 @@ @interface SPUScheduledUpdateDriver() @property (nonatomic, readonly) SPUUIBasedUpdateDriver *uiDriver; -@property (nonatomic, readonly) id updater; -@property (nonatomic, readonly) id updaterDelegate; +@property (nonatomic) BOOL showedUpdate; @end @implementation SPUScheduledUpdateDriver @synthesize uiDriver = _uiDriver; -@synthesize updater = _updater; -@synthesize updaterDelegate = _updaterDelegate; +@synthesize showedUpdate = _showedUpdate; - (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate { self = [super init]; if (self != nil) { _uiDriver = [[SPUUIBasedUpdateDriver alloc] initWithHost:host applicationBundle:applicationBundle sparkleBundle:sparkleBundle updater:updater userDriver:userDriver userInitiated:NO updaterDelegate:updaterDelegate delegate:self]; - _updater = updater; - _updaterDelegate = updaterDelegate; } return self; } @@ -64,30 +60,23 @@ [self.uiDriver resumeUpdate:resumableUpdate completion:completionBlock]; } +- (void)uiDriverDidShowUpdate +{ + self.showedUpdate = YES; +} + - (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *) error { - // Don't tell the user that no update was found or some appcast fetch error occurred for scheduled update checks - [self abortUpdateWithError:nil]; - - [self notifyDelegateAboutError:error]; + // Don't tell the user that no update was found or some appcast fetch error occurred for scheduled update checks if we haven't shown the update + [self abortUpdateWithError:self.showedUpdate ? error : nil]; } - (void)coreDriverIsRequestingAbortUpdateWithError:(nullable NSError *) error { - // Don't tell the user that a non-UI update error occurred for scheduled update checks - [self abortUpdateWithError:nil]; - - [self notifyDelegateAboutError:error]; + // Don't tell the user that an update error occurred for scheduled update checks if we haven't shown the update + [self abortUpdateWithError:self.showedUpdate ? error : nil]; } -- (void)notifyDelegateAboutError:(nullable NSError *)error -{ - if (error == nil) { return; } - if ([self.updaterDelegate respondsToSelector:@selector(updater:scheduledUpdateCheckDidAbortWithError:)]) { - [self.updaterDelegate updater:self.updater scheduledUpdateCheckDidAbortWithError:(NSError * _Nonnull)error]; - } -} - - (void)uiDriverIsRequestingAbortUpdateWithError:(nullable NSError *)error { [self abortUpdateWithError:error]; diff --git a/Sparkle/SPUUIBasedUpdateDriver.h b/Sparkle/SPUUIBasedUpdateDriver.h index c77fa135..188822e7 100644 --- a/Sparkle/SPUUIBasedUpdateDriver.h +++ b/Sparkle/SPUUIBasedUpdateDriver.h @@ -20,6 +20,7 @@ NS_ASSUME_NONNULL_BEGIN @optional - (void)basicDriverDidFinishLoadingAppcast; +- (void)uiDriverDidShowUpdate; @end diff --git a/Sparkle/SPUUIBasedUpdateDriver.m b/Sparkle/SPUUIBasedUpdateDriver.m index d7dd3fc8..c1aae0ab 100644 --- a/Sparkle/SPUUIBasedUpdateDriver.m +++ b/Sparkle/SPUUIBasedUpdateDriver.m @@ -167,6 +167,10 @@ }]; } + if ([self.delegate respondsToSelector:@selector(uiDriverDidShowUpdate)]) { + [self.delegate uiDriverDidShowUpdate]; + } + id updaterDelegate = self.updaterDelegate; if (updateItem.releaseNotesURL != nil && (![updaterDelegate respondsToSelector:@selector(updaterShouldDownloadReleaseNotes:)] || [updaterDelegate updaterShouldDownloadReleaseNotes:self.updater])) { NSURLRequest *request = [NSURLRequest requestWithURL:updateItem.releaseNotesURL cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:30]; diff --git a/Sparkle/SPUUpdaterDelegate.h b/Sparkle/SPUUpdaterDelegate.h index 906a1b40..a336047f 100644 --- a/Sparkle/SPUUpdaterDelegate.h +++ b/Sparkle/SPUUpdaterDelegate.h @@ -333,14 +333,6 @@ typedef NS_ENUM(NSInteger, SPUUpdateCheck) */ - (void)updater:(SPUUpdater *)updater didAbortWithError:(NSError *)error; -/*! - Called after an update is aborted due to an error during an scheduled update check. - - \param updater The updater instance. - \param error The error that caused the abort - */ -- (void)updater:(SPUUpdater *)updater scheduledUpdateCheckDidAbortWithError:(NSError *)error; - @end NS_ASSUME_NONNULL_END