Pass relaunch path to standard user driver from SUUpdater

This commit is contained in:
Zorg committed 2016-08-13 11:55:50 -04:00
1 parent 5114cd9d83
commit ad14421b24
2 files changed
+31 -1

No files matched your search

+22 -1
View File
@@ -35,6 +35,12 @@
@end
@interface NSObject (Private)
- (NSString * _Nullable)_pathToTerminateForStandardUserDriver;
@end
@implementation SPUStandardUserDriver
@synthesize host = _host;
@@ -400,7 +406,22 @@
[self.statusController close];
self.statusController = nil;
[self.uiComponent terminateApplicationForBundle:self.applicationBundle];
// Give the delegate a deferred chance for providing an application path
// This is a private API and used by SUUpdater
NSString *applicationPath = nil;
if ([self.delegate respondsToSelector:@selector(_pathToTerminateForStandardUserDriver)]) {
applicationPath = [(NSObject *)self.delegate _pathToTerminateForStandardUserDriver];
}
NSBundle *applicationBundle;
if (applicationPath != nil) {
applicationBundle = [NSBundle bundleWithPath:applicationPath];
assert(applicationBundle != nil);
} else {
applicationBundle = self.applicationBundle;
}
[self.uiComponent terminateApplicationForBundle:applicationBundle];
});
}
+9
View File
@@ -74,6 +74,9 @@ static NSMutableDictionary *sharedUpdaters = nil;
}
[sharedUpdaters setObject:self forKey:[NSValue valueWithNonretainedObject:bundle]];
// This bundle may not necessarily be the correct application bundle
// Unfortunately we won't know the correct application bundle until after the delegate is set
// See -[SUUpdater _standardUserDriverRequestsPathToRelaunch] below which resolves this
_userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:bundle applicationBundle:bundle delegate:self];
_updater = [[SPUUpdater alloc] initWithHostBundle:bundle userDriver:_userDriver delegate:self];
@@ -408,6 +411,12 @@ static NSMutableDictionary *sharedUpdaters = nil;
return relaunchPath;
}
// Private SPUStandardUserDriver API that allows us to defer providing an application path to terminate
- (NSString * _Nullable)_pathToTerminateForStandardUserDriver
{
return [self pathToRelaunchForUpdater:self.updater];
}
- (NSString *)decryptionPasswordForUpdater:(SPUUpdater *)__unused updater
{
return self.decryptionPassword;