Update postponing code is not as bad as I thought

This commit is contained in:
Zorg committed 2016-02-15 00:08:07 -05:00
1 parent 1cfbffa74c
commit 480feff34f
1 file changed
+15 -14
+15 -14
View File
@@ -31,6 +31,8 @@
@property (copy) NSString *tempDir;
@property (copy) NSString *relaunchPath;
@property (nonatomic) BOOL postponedOnce;
@end
@implementation SUBasicUpdateDriver
@@ -43,6 +45,8 @@
@synthesize tempDir;
@synthesize relaunchPath;
@synthesize postponedOnce;
- (void)checkForUpdatesAtURL:(NSURL *)URL host:(SUHost *)aHost
{
[super checkForUpdatesAtURL:URL host:aHost];
@@ -436,22 +440,19 @@
}
// Give the host app an opportunity to postpone the install and relaunch.
#warning this code is broken and uses a static local instead of ivar, and uses installWithToolAndRelaunch: instead of installWithToolAndRelaunch:displayingUserInterface:
id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
// static BOOL postponedOnce = NO;
// id<SUUpdaterDelegate> updaterDelegate = [self.updater delegate];
// if (!postponedOnce && [updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
// {
// NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
// [invocation setSelector:@selector(installWithToolAndRelaunch:)];
// [invocation setArgument:&relaunch atIndex:2];
// [invocation setTarget:self];
// postponedOnce = YES;
// if ([updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem untilInvoking:invocation]) {
// return;
// }
// }
if (!self.postponedOnce && [updaterDelegate respondsToSelector:@selector(updater:shouldPostponeRelaunchForUpdate:untilInvoking:)])
{
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[[self class] instanceMethodSignatureForSelector:@selector(installWithToolAndRelaunch:)]];
[invocation setSelector:@selector(installWithToolAndRelaunch:)];
[invocation setArgument:&relaunch atIndex:2];
[invocation setTarget:self];
self.postponedOnce = YES;
if ([updaterDelegate updater:self.updater shouldPostponeRelaunchForUpdate:self.updateItem untilInvoking:invocation]) {
return;
}
}
if ([updaterDelegate respondsToSelector:@selector(updater:willInstallUpdate:)]) {