From d362caac98224e56ea88ce164f49da2c8a889032 Mon Sep 17 00:00:00 2001 From: Zorg Date: Mon, 26 Dec 2016 12:58:26 -0500 Subject: [PATCH] Rename applicationPath to bundlePath in SUPlainInstaller This is less confusing. I also documented the SUPlainInstaller initializer method. --- Autoupdate/SUInstaller.m | 2 +- Autoupdate/SUPlainInstaller.h | 8 +++++++- Autoupdate/SUPlainInstaller.m | 12 ++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/Autoupdate/SUInstaller.m b/Autoupdate/SUInstaller.m index 16d44103..12a47417 100644 --- a/Autoupdate/SUInstaller.m +++ b/Autoupdate/SUInstaller.m @@ -165,7 +165,7 @@ installationPath = host.bundlePath; } - installer = [[SUPlainInstaller alloc] initWithHost:host applicationPath:newDownloadPath installationPath:installationPath versionComparator:comparator]; + installer = [[SUPlainInstaller alloc] initWithHost:host bundlePath:newDownloadPath installationPath:installationPath versionComparator:comparator]; } } diff --git a/Autoupdate/SUPlainInstaller.h b/Autoupdate/SUPlainInstaller.h index 8e348bc6..49bb6b3a 100644 --- a/Autoupdate/SUPlainInstaller.h +++ b/Autoupdate/SUPlainInstaller.h @@ -14,6 +14,12 @@ @interface SUPlainInstaller : NSObject -- (instancetype)initWithHost:(SUHost *)host applicationPath:(NSString *)applicationPath installationPath:(NSString *)installationPath versionComparator:(id )comparator; +/*! + @param host The current (old) bundle host + @param bundlePath The path to the new bundle that will be installed. + @param installationPath The path the new bundlePath will be installed to. + @param comparator The version comparator to use to prevent a downgrade from occurring. + */ +- (instancetype)initWithHost:(SUHost *)host bundlePath:(NSString *)bundlePath installationPath:(NSString *)installationPath versionComparator:(id )comparator; @end diff --git a/Autoupdate/SUPlainInstaller.m b/Autoupdate/SUPlainInstaller.m index 286dcc6c..874b4301 100644 --- a/Autoupdate/SUPlainInstaller.m +++ b/Autoupdate/SUPlainInstaller.m @@ -22,7 +22,7 @@ @property (nonatomic, readonly) SUHost *host; @property (nonatomic, readonly) id comparator; -@property (nonatomic, copy, readonly) NSString *applicationPath; +@property (nonatomic, copy, readonly) NSString *bundlePath; @property (nonatomic, copy, readonly) NSString *installationPath; // Properties that carry over from starting installation to resuming to cleaning up @@ -35,17 +35,17 @@ @synthesize host = _host; @synthesize comparator = _comparator; -@synthesize applicationPath = _applicationPath; +@synthesize bundlePath = _bundlePath; @synthesize installationPath = _installationPath; @synthesize tempOldDirectoryURL = _tempOldDirectoryURL; @synthesize tempNewDirectoryURL = _tempNewDirectoryURL; -- (instancetype)initWithHost:(SUHost *)host applicationPath:(NSString *)applicationPath installationPath:(NSString *)installationPath versionComparator:(id )comparator +- (instancetype)initWithHost:(SUHost *)host bundlePath:(NSString *)bundlePath installationPath:(NSString *)installationPath versionComparator:(id )comparator { self = [super init]; if (self != nil) { _host = host; - _applicationPath = [applicationPath copy]; + _bundlePath = [bundlePath copy]; _installationPath = [installationPath copy]; _comparator = comparator; } @@ -196,7 +196,7 @@ // Note that we may not be able to do this for package installations, hence this code being done here if (!allowDowngrades) { NSString *hostVersion = [self.host version]; - NSBundle *bundle = [NSBundle bundleWithPath:self.applicationPath]; + NSBundle *bundle = [NSBundle bundleWithPath:self.bundlePath]; NSString *updateVersion = [bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]; if (!updateVersion || [self.comparator compareVersion:hostVersion toVersion:updateVersion] == NSOrderedDescending) { NSString *errorMessage = [NSString stringWithFormat:@"For security reasons, updates that downgrade version of the application are not allowed. Refusing to downgrade app from version %@ to %@. Aborting update.", hostVersion, [bundle objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]]; @@ -214,7 +214,7 @@ { // Note: we must do most installation work in the third stage due to relying on our application sitting in temporary directories. // It must not be possible for our update to sit in temporary directories for a very long time. - return [self startInstallationToURL:[NSURL fileURLWithPath:self.installationPath] fromUpdateAtURL:[NSURL fileURLWithPath:self.applicationPath] withHost:self.host error:error]; + return [self startInstallationToURL:[NSURL fileURLWithPath:self.installationPath] fromUpdateAtURL:[NSURL fileURLWithPath:self.bundlePath] withHost:self.host error:error]; } - (BOOL)canInstallSilently