From bb7af6145fbc634fd13e525975e2fb6d33de29d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kornel=20Lesin=CC=81ski?= Date: Fri, 24 Apr 2015 10:31:42 +0100 Subject: [PATCH] Removed unused arg --- Sparkle/SUGuidedPackageInstaller.m | 4 +--- Sparkle/SUInstaller.h | 2 +- Sparkle/SUInstaller.m | 7 +++++-- Sparkle/SUPackageInstaller.m | 6 +++--- Sparkle/SUPlainInstaller.m | 6 ++++-- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Sparkle/SUGuidedPackageInstaller.m b/Sparkle/SUGuidedPackageInstaller.m index 6b5ae43d..bc83d42b 100644 --- a/Sparkle/SUGuidedPackageInstaller.m +++ b/Sparkle/SUGuidedPackageInstaller.m @@ -90,10 +90,9 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza @implementation SUGuidedPackageInstaller -+ (void)performInstallationToPath:(NSString *)destinationPath fromPath:(NSString *)packagePath host:(SUHost *)host versionComparator:(id)__unused comparator completionHandler:(void (^)(NSError *))completionHandler ++ (void)performInstallationToPath:(NSString *)destinationPath fromPath:(NSString *)packagePath host:(SUHost *)__unused host versionComparator:(id)__unused comparator completionHandler:(void (^)(NSError *))completionHandler { NSParameterAssert(packagePath); - NSParameterAssert(host); dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ @@ -130,7 +129,6 @@ static BOOL AuthorizationExecuteWithPrivilegesAndWait(AuthorizationRef authoriza dispatch_async(dispatch_get_main_queue(), ^{ [self finishInstallationToPath:destinationPath withResult:validInstallation - host:host error:error completionHandler:completionHandler]; diff --git a/Sparkle/SUInstaller.h b/Sparkle/SUInstaller.h index a1393d6d..fe82f885 100644 --- a/Sparkle/SUInstaller.h +++ b/Sparkle/SUInstaller.h @@ -17,7 +17,7 @@ + (NSString *)appPathInUpdateFolder:(NSString *)updateFolder forHost:(SUHost *)host; + (void)installFromUpdateFolder:(NSString *)updateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath versionComparator:(id)comparator completionHandler:(void (^)(NSError *))completionHandler; -+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result host:(SUHost *)host error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler; ++ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler; + (NSString *)updateFolder; @end diff --git a/Sparkle/SUInstaller.m b/Sparkle/SUInstaller.m index 3035a51e..19d1a718 100644 --- a/Sparkle/SUInstaller.m +++ b/Sparkle/SUInstaller.m @@ -128,7 +128,7 @@ static NSString *sUpdateFolder = nil; NSString *newAppDownloadPath = [self installSourcePathInUpdateFolder:inUpdateFolder forHost:host isPackage:&isPackage isGuided:&isGuided]; if (newAppDownloadPath == nil) { - [self finishInstallationToPath:installationPath withResult:NO host:host error:[NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingUpdateError userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't find an appropriate update in the downloaded package." }] completionHandler:completionHandler]; + [self finishInstallationToPath:installationPath withResult:NO error:[NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingUpdateError userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't find an appropriate update in the downloaded package." }] completionHandler:completionHandler]; } else { if (isPackage && isGuided) { [SUGuidedPackageInstaller performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host versionComparator:comparator completionHandler:completionHandler]; @@ -160,7 +160,7 @@ static NSString *sUpdateFolder = nil; } } -+ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result host:(SUHost *)host error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler ++ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result error:(NSError *)error completionHandler:(void (^)(NSError *))completionHandler { if (result) { [self mdimportInstallationPath:installationPath]; @@ -168,6 +168,9 @@ static NSString *sUpdateFolder = nil; completionHandler(nil); }); } else { + if (!error) { + error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:nil]; + } dispatch_async(dispatch_get_main_queue(), ^{ completionHandler(error); }); diff --git a/Sparkle/SUPackageInstaller.m b/Sparkle/SUPackageInstaller.m index 8c4bef05..64637433 100644 --- a/Sparkle/SUPackageInstaller.m +++ b/Sparkle/SUPackageInstaller.m @@ -12,7 +12,7 @@ @implementation SUPackageInstaller -+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host versionComparator:(id)__unused comparator completionHandler:(void (^)(NSError *))completionHandler ++ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)__unused host versionComparator:(id)__unused comparator completionHandler:(void (^)(NSError *))completionHandler { // Run installer using the "open" command to ensure it is launched in front of current application. // -W = wait until the app has quit. @@ -23,7 +23,7 @@ if (![[NSFileManager defaultManager] fileExistsAtPath:command]) { NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUMissingInstallerToolError userInfo:@{ NSLocalizedDescriptionKey: @"Couldn't find Apple's installer tool!" }]; - [self finishInstallationToPath:installationPath withResult:NO host:host error:error completionHandler:completionHandler]; + [self finishInstallationToPath:installationPath withResult:NO error:error completionHandler:completionHandler]; return; } @@ -33,7 +33,7 @@ // Known bug: if the installation fails or is canceled, Sparkle goes ahead and restarts, thinking everything is fine. dispatch_async(dispatch_get_main_queue(), ^{ - [self finishInstallationToPath:installationPath withResult:YES host:host error:nil completionHandler:completionHandler]; + [self finishInstallationToPath:installationPath withResult:YES error:nil completionHandler:completionHandler]; }); }); } diff --git a/Sparkle/SUPlainInstaller.m b/Sparkle/SUPlainInstaller.m index 9d197b70..1aeb6317 100644 --- a/Sparkle/SUPlainInstaller.m +++ b/Sparkle/SUPlainInstaller.m @@ -16,12 +16,14 @@ + (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host versionComparator:(id)comparator completionHandler:(void (^)(NSError *))completionHandler { + NSParameterAssert(host); + // Prevent malicious downgrades if (![[[NSBundle bundleWithIdentifier:SUBundleIdentifier] infoDictionary][SUEnableAutomatedDowngradesKey] boolValue]) { if ([comparator compareVersion:[host version] toVersion:[[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]] == NSOrderedDescending) { NSString *errorMessage = [NSString stringWithFormat:@"Sparkle Updater: Possible attack in progress! Attempting to \"upgrade\" from %@ to %@. Aborting update.", [host version], [[NSBundle bundleWithPath:path] objectForInfoDictionaryKey:(__bridge NSString *)kCFBundleVersionKey]]; NSError *error = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDowngradeError userInfo:@{ NSLocalizedDescriptionKey: errorMessage }]; - [self finishInstallationToPath:installationPath withResult:NO host:host error:error completionHandler:completionHandler]; + [self finishInstallationToPath:installationPath withResult:NO error:error completionHandler:completionHandler]; return; } } @@ -51,7 +53,7 @@ } dispatch_async(dispatch_get_main_queue(), ^{ - [self finishInstallationToPath:installationPath withResult:result host:host error:error completionHandler:completionHandler]; + [self finishInstallationToPath:installationPath withResult:result error:error completionHandler:completionHandler]; }); }); }