mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Merge pull request #1753 from sparkle-project/fix-swallow-scheduled-ui-error
Don't swallow errors for scheduled driver after update is shown
This commit is contained in:
4 files changed
+16
-30
No files matched your search
Vendored
+11
-22
@@ -18,24 +18,20 @@
|
||||
@interface SPUScheduledUpdateDriver() <SPUUIBasedUpdateDriverDelegate>
|
||||
|
||||
@property (nonatomic, readonly) SPUUIBasedUpdateDriver *uiDriver;
|
||||
@property (nonatomic, readonly) id updater;
|
||||
@property (nonatomic, readonly) id <SPUUpdaterDelegate> 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 <SPUUserDriver>)userDriver updaterDelegate:(nullable id <SPUUpdaterDelegate>)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];
|
||||
|
||||
Vendored
+1
@@ -20,6 +20,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||
@optional
|
||||
|
||||
- (void)basicDriverDidFinishLoadingAppcast;
|
||||
- (void)uiDriverDidShowUpdate;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
Vendored
+4
@@ -167,6 +167,10 @@
|
||||
}];
|
||||
}
|
||||
|
||||
if ([self.delegate respondsToSelector:@selector(uiDriverDidShowUpdate)]) {
|
||||
[self.delegate uiDriverDidShowUpdate];
|
||||
}
|
||||
|
||||
id <SPUUpdaterDelegate> 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];
|
||||
|
||||
Vendored
-8
@@ -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
|
||||
Reference in new issue
Block a user