From 29d790c63c0fd047ffa0e41ac3045e674469acba Mon Sep 17 00:00:00 2001 From: Zorg Date: Sat, 13 Aug 2016 12:57:26 -0400 Subject: [PATCH] Pass application bundle into SPUUpdater instead of relying on delegate method --- Sparkle/SPUStandardUpdaterController.m | 2 +- Sparkle/SPUUpdater.h | 3 ++- Sparkle/SPUUpdater.m | 15 ++++++++++----- Sparkle/SPUUpdaterDelegate.h | 12 ------------ Sparkle/SUAutomaticUpdateDriver.h | 2 +- Sparkle/SUAutomaticUpdateDriver.m | 4 ++-- Sparkle/SUCoreBasedUpdateDriver.h | 2 +- Sparkle/SUCoreBasedUpdateDriver.m | 4 ++-- Sparkle/SUInstallerDriver.h | 2 +- Sparkle/SUInstallerDriver.m | 18 ++++++++++++++---- Sparkle/SUScheduledUpdateDriver.h | 2 +- Sparkle/SUScheduledUpdateDriver.m | 4 ++-- Sparkle/SUUIBasedUpdateDriver.h | 2 +- Sparkle/SUUIBasedUpdateDriver.m | 4 ++-- Sparkle/SUUpdater.m | 9 +++++---- Sparkle/SUUserInitiatedUpdateDriver.h | 2 +- Sparkle/SUUserInitiatedUpdateDriver.m | 4 ++-- .../SUUpdateSettingsWindowController.m | 2 +- Tests/SUUpdaterTest.m | 7 ++++--- sparkle-cli/SPUCommandLineDriver.m | 11 +---------- 20 files changed, 54 insertions(+), 57 deletions(-) diff --git a/Sparkle/SPUStandardUpdaterController.m b/Sparkle/SPUStandardUpdaterController.m index 6167612d..325f2a55 100644 --- a/Sparkle/SPUStandardUpdaterController.m +++ b/Sparkle/SPUStandardUpdaterController.m @@ -41,7 +41,7 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults NSBundle *hostBundle = [NSBundle mainBundle]; id userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:hostBundle applicationBundle:hostBundle delegate:self.userDriverDelegate]; - self.updater = [[SPUUpdater alloc] initWithHostBundle:hostBundle userDriver:userDriver delegate:self.updaterDelegate]; + self.updater = [[SPUUpdater alloc] initWithHostBundle:hostBundle applicationBundle:hostBundle userDriver:userDriver delegate:self.updaterDelegate]; self.userDriver = userDriver; // In the case this is being called right as an application is being launched, diff --git a/Sparkle/SPUUpdater.h b/Sparkle/SPUUpdater.h index e84966c8..646181aa 100644 --- a/Sparkle/SPUUpdater.h +++ b/Sparkle/SPUUpdater.h @@ -39,12 +39,13 @@ SU_EXPORT @interface SPUUpdater : NSObject * Related: See SPUStandardUpdaterController which wraps a SPUUpdater instance and is suitable for instantiating in nib files * * @param hostBundle The bundle that should be targetted for updating. This must not be nil. + * @param applicationBundle The application bundle that should be relaunched and waited for termination. Usually this can be the same as hostBundle. * @param userDriver The user driver that Sparkle uses for user update interaction * @param delegate The delegate for SPUUpdater. This may be nil. * * This must be called on the main thread. */ -- (instancetype)initWithHostBundle:(NSBundle *)hostBundle userDriver:(id )userDriver delegate:(id _Nullable)delegate; +- (instancetype)initWithHostBundle:(NSBundle *)hostBundle applicationBundle:(NSBundle *)applicationBundle userDriver:(id )userDriver delegate:(id _Nullable)delegate; /*! * Starts the updater. diff --git a/Sparkle/SPUUpdater.m b/Sparkle/SPUUpdater.m index 702b686e..f7087d7b 100644 --- a/Sparkle/SPUUpdater.m +++ b/Sparkle/SPUUpdater.m @@ -46,6 +46,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification @property (nonatomic) id driver; @property (nonatomic, readonly) SUHost *host; +@property (nonatomic, readonly) NSBundle *applicationBundle; @property (nonatomic, readonly) SPUUpdaterSettings *updaterSettings; @property (nonatomic, readonly) SPUUpdaterCycle *updaterCycle; @property (nonatomic, readonly) SPUUpdaterTimer *updaterTimer; @@ -66,6 +67,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification @synthesize httpHeaders; @synthesize driver; @synthesize host = _host; +@synthesize applicationBundle = _applicationBundle; @synthesize updaterSettings = _updaterSettings; @synthesize updaterCycle = _updaterCycle; @synthesize updaterTimer = _updaterTimer; @@ -85,7 +87,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification } #endif -- (instancetype)initWithHostBundle:(NSBundle *)bundle userDriver:(id )userDriver delegate:(id )theDelegate +- (instancetype)initWithHostBundle:(NSBundle *)hostBundle applicationBundle:(NSBundle *)applicationBundle userDriver:(id )userDriver delegate:(id _Nullable)delegate { self = [super init]; @@ -93,15 +95,16 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification // Use explicit class to use the correct bundle even when subclassed _sparkleBundle = [NSBundle bundleForClass:[SPUUpdater class]]; - _host = [[SUHost alloc] initWithBundle:bundle]; + _host = [[SUHost alloc] initWithBundle:hostBundle]; + _applicationBundle = applicationBundle; - _updaterSettings = [[SPUUpdaterSettings alloc] initWithHostBundle:bundle]; + _updaterSettings = [[SPUUpdaterSettings alloc] initWithHostBundle:hostBundle]; _updaterCycle = [[SPUUpdaterCycle alloc] initWithDelegate:self]; _updaterTimer = [[SPUUpdaterTimer alloc] initWithDelegate:self]; _userDriver = userDriver; - _delegate = theDelegate; + _delegate = delegate; } return self; @@ -410,6 +413,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification updateDriver = [[SUAutomaticUpdateDriver alloc] initWithHost:strongSelf.host + applicationBundle:strongSelf.applicationBundle sparkleBundle:strongSelf.sparkleBundle updater:strongSelf userDriver:strongSelf.userDriver @@ -418,6 +422,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification updateDriver = [[SUScheduledUpdateDriver alloc] initWithHost:strongSelf.host + applicationBundle:strongSelf.applicationBundle sparkleBundle:strongSelf.sparkleBundle updater:strongSelf userDriver:strongSelf.userDriver @@ -443,7 +448,7 @@ NSString *const SUUpdaterAppcastNotificationKey = @"SUUpdaterAppCastNotification return; } - id theUpdateDriver = [[SUUserInitiatedUpdateDriver alloc] initWithHost:self.host sparkleBundle:self.sparkleBundle updater:self userDriver:self.userDriver updaterDelegate:self.delegate]; + id theUpdateDriver = [[SUUserInitiatedUpdateDriver alloc] initWithHost:self.host applicationBundle:self.applicationBundle sparkleBundle:self.sparkleBundle updater:self userDriver:self.userDriver updaterDelegate:self.delegate]; NSString *bundleIdentifier = self.host.bundle.bundleIdentifier; assert(bundleIdentifier != nil); diff --git a/Sparkle/SPUUpdaterDelegate.h b/Sparkle/SPUUpdaterDelegate.h index 2192521e..b62202ec 100644 --- a/Sparkle/SPUUpdaterDelegate.h +++ b/Sparkle/SPUUpdaterDelegate.h @@ -211,18 +211,6 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey; */ - (nullable id)versionComparatorForUpdater:(SPUUpdater *)updater; -/*! - Returns the path to the application which is used to relaunch after the update is installed. - - The installer also waits for the termination of the application at this path. - - The default is the path of the host bundle. - - \param updater The updater instance. - \return The path to the application bundle to relaunch and wait for termination, or nil if you don't want to be delegated this task. - */ -- (nullable NSString *)pathToRelaunchForUpdater:(SPUUpdater *)updater; - /*! Returns whether or not the updater should allow interaction with its installer diff --git a/Sparkle/SUAutomaticUpdateDriver.h b/Sparkle/SUAutomaticUpdateDriver.h index f70bf4b0..eafae87e 100644 --- a/Sparkle/SUAutomaticUpdateDriver.h +++ b/Sparkle/SUAutomaticUpdateDriver.h @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN @interface SUAutomaticUpdateDriver : NSObject -- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate; +- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate; @end diff --git a/Sparkle/SUAutomaticUpdateDriver.m b/Sparkle/SUAutomaticUpdateDriver.m index bcce9d8f..dcf6ef94 100644 --- a/Sparkle/SUAutomaticUpdateDriver.m +++ b/Sparkle/SUAutomaticUpdateDriver.m @@ -40,7 +40,7 @@ @synthesize updateItem = _updateItem; @synthesize willInstallSilently = _willInstallSilently; -- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate +- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate { self = [super init]; if (self != nil) { @@ -48,7 +48,7 @@ // The user driver is only used for a termination callback _userDriver = userDriver; _updaterDelegate = updaterDelegate; - _coreDriver = [[SUCoreBasedUpdateDriver alloc] initWithHost:host sparkleBundle:sparkleBundle updater:updater updaterDelegate:updaterDelegate delegate:self]; + _coreDriver = [[SUCoreBasedUpdateDriver alloc] initWithHost:host applicationBundle:applicationBundle sparkleBundle:sparkleBundle updater:updater updaterDelegate:updaterDelegate delegate:self]; } return self; } diff --git a/Sparkle/SUCoreBasedUpdateDriver.h b/Sparkle/SUCoreBasedUpdateDriver.h index 5a14611e..7f296316 100644 --- a/Sparkle/SUCoreBasedUpdateDriver.h +++ b/Sparkle/SUCoreBasedUpdateDriver.h @@ -49,7 +49,7 @@ NS_ASSUME_NONNULL_BEGIN @interface SUCoreBasedUpdateDriver : NSObject -- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id )updaterDelegate delegate:(id)delegate; +- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id )updaterDelegate delegate:(id)delegate; - (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates requiresSilentInstall:(BOOL)silentInstall completion:(SUUpdateDriverCompletion)completionBlock; diff --git a/Sparkle/SUCoreBasedUpdateDriver.m b/Sparkle/SUCoreBasedUpdateDriver.m index 882581df..9bd11d05 100644 --- a/Sparkle/SUCoreBasedUpdateDriver.m +++ b/Sparkle/SUCoreBasedUpdateDriver.m @@ -53,7 +53,7 @@ @synthesize userAgent = _userAgent; @synthesize downloadedUpdate = _downloadedUpdate; -- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id )updaterDelegate delegate:(id)delegate +- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id )updaterDelegate delegate:(id)delegate { self = [super init]; if (self != nil) { @@ -63,7 +63,7 @@ assert(bundleIdentifier != nil); _basicDriver = [[SUBasicUpdateDriver alloc] initWithHost:host updater:updater updaterDelegate:updaterDelegate delegate:self]; - _installerDriver = [[SUInstallerDriver alloc] initWithHost:host sparkleBundle:sparkleBundle updater:updater updaterDelegate:updaterDelegate delegate:self]; + _installerDriver = [[SUInstallerDriver alloc] initWithHost:host applicationBundle:applicationBundle sparkleBundle:sparkleBundle updater:updater updaterDelegate:updaterDelegate delegate:self]; _host = host; _updater = updater; diff --git a/Sparkle/SUInstallerDriver.h b/Sparkle/SUInstallerDriver.h index 9b6ff664..ea435136 100644 --- a/Sparkle/SUInstallerDriver.h +++ b/Sparkle/SUInstallerDriver.h @@ -29,7 +29,7 @@ NS_ASSUME_NONNULL_BEGIN @interface SUInstallerDriver : NSObject -- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id)updaterDelegate delegate:(nullable id)delegate; +- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(nullable id)updaterDelegate delegate:(nullable id)delegate; - (void)resumeInstallingUpdateWithUpdateItem:(SUAppcastItem *)updateItem; diff --git a/Sparkle/SUInstallerDriver.m b/Sparkle/SUInstallerDriver.m index 4b212e94..bab49760 100644 --- a/Sparkle/SUInstallerDriver.m +++ b/Sparkle/SUInstallerDriver.m @@ -31,9 +31,16 @@ #define FIRST_INSTALLER_MESSAGE_TIMEOUT 7ull +@interface NSObject (PrivateDelegateMethods) + +- (nullable NSString *)_pathToRelaunchForUpdater:(SPUUpdater *)updater; + +@end + @interface SUInstallerDriver () @property (nonatomic, readonly) SUHost *host; +@property (nonatomic, readonly) NSBundle *applicationBundle; @property (nonatomic, readonly) NSBundle *sparkleBundle; @property (nonatomic, weak, readonly) id delegate; @property (nonatomic) SPUInstallerMessageType currentStage; @@ -58,6 +65,7 @@ @implementation SUInstallerDriver @synthesize host = _host; +@synthesize applicationBundle = _applicationBundle; @synthesize sparkleBundle = _sparkleBundle; @synthesize delegate = _delegate; @synthesize currentStage = _currentStage; @@ -73,11 +81,12 @@ @synthesize temporaryDirectory = _temporaryDirectory; @synthesize aborted = _aborted; -- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(id)updaterDelegate delegate:(nullable id)delegate +- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater updaterDelegate:(id)updaterDelegate delegate:(nullable id)delegate { self = [super init]; if (self != nil) { _host = host; + _applicationBundle = applicationBundle; _sparkleBundle = sparkleBundle; _updater = updater; _updaterDelegate = updaterDelegate; @@ -154,9 +163,10 @@ - (void)sendInstallationData { - NSString *pathToRelaunch = [self.host bundlePath]; - if ([self.updaterDelegate respondsToSelector:@selector(pathToRelaunchForUpdater:)]) { - NSString *relaunchPath = [self.updaterDelegate pathToRelaunchForUpdater:self.updater]; + NSString *pathToRelaunch = self.applicationBundle.bundlePath; + // Give the delegate one more chance for determining the path to relaunch via a private API used by SUUpdater + if ([self.updaterDelegate respondsToSelector:@selector(_pathToRelaunchForUpdater:)]) { + NSString *relaunchPath = [(NSObject *)self.updaterDelegate _pathToRelaunchForUpdater:self.updater]; if (relaunchPath != nil) { pathToRelaunch = relaunchPath; } diff --git a/Sparkle/SUScheduledUpdateDriver.h b/Sparkle/SUScheduledUpdateDriver.h index 0c64ecb5..05659c82 100644 --- a/Sparkle/SUScheduledUpdateDriver.h +++ b/Sparkle/SUScheduledUpdateDriver.h @@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN @interface SUScheduledUpdateDriver : NSObject -- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate; +- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate; @end diff --git a/Sparkle/SUScheduledUpdateDriver.m b/Sparkle/SUScheduledUpdateDriver.m index a1a34000..279d4acf 100644 --- a/Sparkle/SUScheduledUpdateDriver.m +++ b/Sparkle/SUScheduledUpdateDriver.m @@ -26,11 +26,11 @@ @synthesize uiDriver = _uiDriver; -- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate +- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate { self = [super init]; if (self != nil) { - _uiDriver = [[SUUIBasedUpdateDriver alloc] initWithHost:host sparkleBundle:sparkleBundle updater:updater userDriver:userDriver updaterDelegate:updaterDelegate delegate:self]; + _uiDriver = [[SUUIBasedUpdateDriver alloc] initWithHost:host applicationBundle:applicationBundle sparkleBundle:sparkleBundle updater:updater userDriver:userDriver updaterDelegate:updaterDelegate delegate:self]; } return self; } diff --git a/Sparkle/SUUIBasedUpdateDriver.h b/Sparkle/SUUIBasedUpdateDriver.h index 0ef5f9a0..2958292b 100644 --- a/Sparkle/SUUIBasedUpdateDriver.h +++ b/Sparkle/SUUIBasedUpdateDriver.h @@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN @interface SUUIBasedUpdateDriver : NSObject -- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate delegate:(id)delegate; +- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate delegate:(id)delegate; - (void)checkForUpdatesAtAppcastURL:(NSURL *)appcastURL withUserAgent:(NSString *)userAgent httpHeaders:(NSDictionary *)httpHeaders includesSkippedUpdates:(BOOL)includesSkippedUpdates completion:(SUUpdateDriverCompletion)completionBlock; diff --git a/Sparkle/SUUIBasedUpdateDriver.m b/Sparkle/SUUIBasedUpdateDriver.m index 9272bc80..c094acbd 100644 --- a/Sparkle/SUUIBasedUpdateDriver.m +++ b/Sparkle/SUUIBasedUpdateDriver.m @@ -45,7 +45,7 @@ @synthesize resumingInstallingUpdate = _resumingInstallingUpdate; @synthesize resumingDownloadedUpdate = _resumingDownloadedUpdate; -- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate delegate:(id)delegate +- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate delegate:(id)delegate { self = [super init]; if (self != nil) { @@ -55,7 +55,7 @@ _updaterDelegate = updaterDelegate; _host = host; - _coreDriver = [[SUCoreBasedUpdateDriver alloc] initWithHost:host sparkleBundle:sparkleBundle updater:updater updaterDelegate:updaterDelegate delegate:self]; + _coreDriver = [[SUCoreBasedUpdateDriver alloc] initWithHost:host applicationBundle:applicationBundle sparkleBundle:sparkleBundle updater:updater updaterDelegate:updaterDelegate delegate:self]; } return self; } diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index 3362a81a..e4a6ddc8 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -76,9 +76,9 @@ static NSMutableDictionary *sharedUpdaters = nil; // 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 + // See -[SUUpdater _standardUserDriverRequestsPathToRelaunch] and -[SUUpdater _pathToRelaunchForUpdater:] implemented below which resolves this _userDriver = [[SPUStandardUserDriver alloc] initWithHostBundle:bundle applicationBundle:bundle delegate:self]; - _updater = [[SPUUpdater alloc] initWithHostBundle:bundle userDriver:_userDriver delegate:self]; + _updater = [[SPUUpdater alloc] initWithHostBundle:bundle applicationBundle:bundle userDriver:_userDriver delegate:self]; NSError *updaterError = nil; if (![_updater startUpdater:&updaterError]) { @@ -402,7 +402,8 @@ static NSMutableDictionary *sharedUpdaters = nil; return versionComparator; } -- (NSString *)pathToRelaunchForUpdater:(SPUUpdater *)__unused updater +// Private SPUUpdater API that allows us to defer providing an application path to relaunch +- (NSString * _Nullable)_pathToRelaunchForUpdater:(SPUUpdater *)__unused updater { NSString *relaunchPath = nil; if ([self.delegate respondsToSelector:@selector(pathToRelaunchForUpdater:)]) { @@ -414,7 +415,7 @@ static NSMutableDictionary *sharedUpdaters = nil; // Private SPUStandardUserDriver API that allows us to defer providing an application path to terminate - (NSString * _Nullable)_pathToTerminateForStandardUserDriver { - return [self pathToRelaunchForUpdater:self.updater]; + return [self _pathToRelaunchForUpdater:self.updater]; } - (NSString *)decryptionPasswordForUpdater:(SPUUpdater *)__unused updater diff --git a/Sparkle/SUUserInitiatedUpdateDriver.h b/Sparkle/SUUserInitiatedUpdateDriver.h index 7d0b1f27..71d8432c 100644 --- a/Sparkle/SUUserInitiatedUpdateDriver.h +++ b/Sparkle/SUUserInitiatedUpdateDriver.h @@ -16,7 +16,7 @@ NS_ASSUME_NONNULL_BEGIN @interface SUUserInitiatedUpdateDriver : NSObject -- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate; +- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate; @end diff --git a/Sparkle/SUUserInitiatedUpdateDriver.m b/Sparkle/SUUserInitiatedUpdateDriver.m index aaf37121..c0848a79 100644 --- a/Sparkle/SUUserInitiatedUpdateDriver.m +++ b/Sparkle/SUUserInitiatedUpdateDriver.m @@ -28,11 +28,11 @@ @synthesize userDriver = _userDriver; @synthesize showingUserInitiatedProgress = _showingUserInitiatedProgress; -- (instancetype)initWithHost:(SUHost *)host sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate +- (instancetype)initWithHost:(SUHost *)host applicationBundle:(NSBundle *)applicationBundle sparkleBundle:(NSBundle *)sparkleBundle updater:(id)updater userDriver:(id )userDriver updaterDelegate:(nullable id )updaterDelegate { self = [super init]; if (self != nil) { - _uiDriver = [[SUUIBasedUpdateDriver alloc] initWithHost:host sparkleBundle:sparkleBundle updater:updater userDriver:userDriver updaterDelegate:updaterDelegate delegate:self]; + _uiDriver = [[SUUIBasedUpdateDriver alloc] initWithHost:host applicationBundle:applicationBundle sparkleBundle:sparkleBundle updater:updater userDriver:userDriver updaterDelegate:updaterDelegate delegate:self]; _userDriver = userDriver; } return self; diff --git a/TestApplication/SUUpdateSettingsWindowController.m b/TestApplication/SUUpdateSettingsWindowController.m index 51789682..f0e65ac7 100644 --- a/TestApplication/SUUpdateSettingsWindowController.m +++ b/TestApplication/SUUpdateSettingsWindowController.m @@ -41,7 +41,7 @@ } self.userDriver = userDriver; - self.updater = [[SPUUpdater alloc] initWithHostBundle:hostBundle userDriver:userDriver delegate:nil]; + self.updater = [[SPUUpdater alloc] initWithHostBundle:hostBundle applicationBundle:applicationBundle userDriver:userDriver delegate:nil]; NSError *updaterError = nil; if (![self.updater startUpdater:&updaterError]) { diff --git a/Tests/SUUpdaterTest.m b/Tests/SUUpdaterTest.m index 618555dc..6ded7404 100644 --- a/Tests/SUUpdaterTest.m +++ b/Tests/SUUpdaterTest.m @@ -24,11 +24,12 @@ { [super setUp]; - // We really want a useless / not really functional user driver so we will pass nil here - // For real world applications we should pass a valid user driver which is why this is not a nullable parameter + NSBundle *bundle = [NSBundle bundleForClass:[self class]]; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnonnull" - self.updater = [[SPUUpdater alloc] initWithHostBundle:[NSBundle bundleForClass:[self class]] userDriver:nil delegate:self]; + // We really want a useless / not really functional user driver so we will pass nil here + // For real world applications we should pass a valid user driver which is why this is not a nullable parameter + self.updater = [[SPUUpdater alloc] initWithHostBundle:bundle applicationBundle:bundle userDriver:nil delegate:self]; #pragma clang diagnostic pop NSError *error = nil; diff --git a/sparkle-cli/SPUCommandLineDriver.m b/sparkle-cli/SPUCommandLineDriver.m index 44648587..cb4a3f22 100644 --- a/sparkle-cli/SPUCommandLineDriver.m +++ b/sparkle-cli/SPUCommandLineDriver.m @@ -15,7 +15,6 @@ void _SULogDisableStandardErrorStream(void); @interface SPUCommandLineDriver () @property (nonatomic, readonly) SPUUpdater *updater; -@property (nonatomic, readonly) NSString *applicationBundlePath; @property (nonatomic, readonly) BOOL verbose; @property (nonatomic) BOOL probingForUpdates; @property (nonatomic, readonly) BOOL interactive; @@ -25,7 +24,6 @@ void _SULogDisableStandardErrorStream(void); @implementation SPUCommandLineDriver @synthesize updater = _updater; -@synthesize applicationBundlePath = _applicationBundlePath; @synthesize verbose = _verbose; @synthesize probingForUpdates = _probingForUpdates; @synthesize interactive = _interactive; @@ -52,14 +50,12 @@ void _SULogDisableStandardErrorStream(void); _verbose = verbose; _interactive = interactiveInstallation; - _applicationBundlePath = applicationBundle.bundlePath; - #ifndef DEBUG _SULogDisableStandardErrorStream(); #endif id userDriver = [[SPUCommandLineUserDriver alloc] initWithApplicationBundle:applicationBundle updatePermission:updatePermission deferInstallation:deferInstallation verbose:verbose]; - _updater = [[SPUUpdater alloc] initWithHostBundle:updateBundle userDriver:userDriver delegate:self]; + _updater = [[SPUUpdater alloc] initWithHostBundle:updateBundle applicationBundle:applicationBundle userDriver:userDriver delegate:self]; } return self; } @@ -104,11 +100,6 @@ void _SULogDisableStandardErrorStream(void); } } -- (NSString *)pathToRelaunchForUpdater:(SPUUpdater *)__unused updater -{ - return self.applicationBundlePath; -} - - (BOOL)updaterShouldDownloadReleaseNotes:(SPUUpdater *)__unused updater { return self.verbose;