From 06573e4b813532bc57232bdffa7ed28854633fef Mon Sep 17 00:00:00 2001 From: Isaac Greenspan Date: Tue, 7 Jul 2015 12:35:49 -0500 Subject: [PATCH 1/2] Add delegate methods for pre-download and immediately post-failed-download. --- Sparkle/SUBasicUpdateDriver.m | 11 +++++++++++ Sparkle/SUUpdater.h | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index d6f72f53..b3600ccf 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -191,6 +191,11 @@ { NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[self.updateItem fileURL]]; [request setValue:[self.updater userAgentString] forHTTPHeaderField:@"User-Agent"]; + if ([[self.updater delegate] respondsToSelector:@selector(updater:willDownloadUpdate:withRequest:)]) { + [[self.updater delegate] updater:self.updater + willDownloadUpdate:self.updateItem + withRequest:request]; + } self.download = [[NSURLDownload alloc] initWithRequest:request delegate:self]; } @@ -309,6 +314,12 @@ if (!failingUrl) { failingUrl = [self.updateItem fileURL]; } + + if ([[self.updater delegate] respondsToSelector:@selector(updater:failedToDownloadUpdate:error:)]) { + [[self.updater delegate] updater:self.updater + failedToDownloadUpdate:self.updateItem + error:error]; + } [self abortUpdateWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SURelaunchError userInfo:@{ NSLocalizedDescriptionKey: SULocalizedString(@"An error occurred while downloading the update. Please try again later.", nil), diff --git a/Sparkle/SUUpdater.h b/Sparkle/SUUpdater.h index ea52e53d..efa6fcd6 100644 --- a/Sparkle/SUUpdater.h +++ b/Sparkle/SUUpdater.h @@ -209,6 +209,24 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey; */ - (void)updaterDidNotFindUpdate:(SUUpdater *)updater; +/*! + Called immediately before downloading the specified update. + + \param updater The SUUpdater instance. + \param item The appcast item corresponding to the update that is proposed to be downloaded. + \param request The mutable URL request that will be used to download the update. + */ +- (void)updater:(SUUpdater *)updater willDownloadUpdate:(SUAppcastItem *)item withRequest:(NSMutableURLRequest *)request; + +/*! + Called after the specified update failed to download. + + \param updater The SUUpdater instance. + \param item The appcast item corresponding to the update that failed to download. + \param error The error generated by the failed download. + */ +- (void)updater:(SUUpdater *)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error; + /*! Called immediately before installing the specified update. From 363a41234de7537f0a01ce8bd532611951ba1937 Mon Sep 17 00:00:00 2001 From: Isaac Greenspan Date: Tue, 7 Jul 2015 12:44:14 -0500 Subject: [PATCH 2/2] Indent new documenting comments to match existing ones. --- Sparkle/SUUpdater.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Sparkle/SUUpdater.h b/Sparkle/SUUpdater.h index efa6fcd6..3ac4828a 100644 --- a/Sparkle/SUUpdater.h +++ b/Sparkle/SUUpdater.h @@ -210,20 +210,20 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey; - (void)updaterDidNotFindUpdate:(SUUpdater *)updater; /*! - Called immediately before downloading the specified update. - - \param updater The SUUpdater instance. - \param item The appcast item corresponding to the update that is proposed to be downloaded. - \param request The mutable URL request that will be used to download the update. + Called immediately before downloading the specified update. + + \param updater The SUUpdater instance. + \param item The appcast item corresponding to the update that is proposed to be downloaded. + \param request The mutable URL request that will be used to download the update. */ - (void)updater:(SUUpdater *)updater willDownloadUpdate:(SUAppcastItem *)item withRequest:(NSMutableURLRequest *)request; /*! - Called after the specified update failed to download. - - \param updater The SUUpdater instance. - \param item The appcast item corresponding to the update that failed to download. - \param error The error generated by the failed download. + Called after the specified update failed to download. + + \param updater The SUUpdater instance. + \param item The appcast item corresponding to the update that failed to download. + \param error The error generated by the failed download. */ - (void)updater:(SUUpdater *)updater failedToDownloadUpdate:(SUAppcastItem *)item error:(NSError *)error;