mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-27 05:04:27 +00:00
Let SPUUpdaterDelegate handle errors currently suppressed (#1494)
* Let SPUUpdaterDelegate handle errors which are suppressed when calling the user driver
This commit is contained in:
1 parent
67819be18a
commit
d9cce796cb
2 files changed
+28
-2
No files matched your search
Vendored
+20
-2
@@ -18,18 +18,24 @@
|
||||
@interface SPUScheduledUpdateDriver() <SPUUIBasedUpdateDriverDelegate>
|
||||
|
||||
@property (nonatomic, readonly) SPUUIBasedUpdateDriver *uiDriver;
|
||||
@property (nonatomic, readonly) id updater;
|
||||
@property (nonatomic, readonly) id <SPUUpdaterDelegate> updaterDelegate;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SPUScheduledUpdateDriver
|
||||
|
||||
@synthesize uiDriver = _uiDriver;
|
||||
@synthesize updater = _updater;
|
||||
@synthesize updaterDelegate = _updaterDelegate;
|
||||
|
||||
- (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;
|
||||
}
|
||||
@@ -58,18 +64,30 @@
|
||||
[self.uiDriver resumeUpdate:resumableUpdate completion:completionBlock];
|
||||
}
|
||||
|
||||
- (void)basicDriverIsRequestingAbortUpdateWithError:(nullable NSError *)__unused error
|
||||
- (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];
|
||||
}
|
||||
|
||||
- (void)coreDriverIsRequestingAbortUpdateWithError:(nullable NSError *)__unused error
|
||||
- (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];
|
||||
}
|
||||
|
||||
- (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
+8
@@ -300,6 +300,14 @@ 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