diff --git a/Sparkle/Autoupdate/Autoupdate.m b/Sparkle/Autoupdate/Autoupdate.m index d5cd3c10..bf7bd6a3 100644 --- a/Sparkle/Autoupdate/Autoupdate.m +++ b/Sparkle/Autoupdate/Autoupdate.m @@ -157,11 +157,11 @@ static const NSTimeInterval SUParentQuitCheckInterval = .5; [statusCtl release]; } - [SUInstaller installFromUpdateFolder: [[NSFileManager defaultManager] stringWithFileSystemRepresentation: folderpath length: strlen(folderpath)] - overHost: host - installationPath: installationPath - delegate: self synchronously: NO - versionComparator: [SUStandardVersionComparator defaultComparator]]; + [SUInstaller installFromUpdateFolder:[[NSFileManager defaultManager] stringWithFileSystemRepresentation:folderpath length:strlen(folderpath)] + overHost:host + installationPath:installationPath + delegate:self + versionComparator:[SUStandardVersionComparator defaultComparator]]; } - (void)installerFinishedForHost:(SUHost *) __unused aHost diff --git a/Sparkle/SUInstaller.h b/Sparkle/SUInstaller.h index 0277d792..c1b01898 100644 --- a/Sparkle/SUInstaller.h +++ b/Sparkle/SUInstaller.h @@ -16,10 +16,12 @@ @class SUHost; @interface SUInstaller : NSObject -+ (NSString *) appPathInUpdateFolder:(NSString *)updateFolder forHost:(SUHost *)host; -+ (void) installFromUpdateFolder:(NSString *)updateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath delegate:(id)delegate synchronously:(BOOL)synchronously versionComparator:(id )comparator; -+ (void) finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result host:(SUHost *)host error:(NSError *)error delegate:(id)delegate; -+ (NSString*) updateFolder; + ++ (NSString *)appPathInUpdateFolder:(NSString *)updateFolder forHost:(SUHost *)host; ++ (void)installFromUpdateFolder:(NSString *)updateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath delegate:(id)delegate versionComparator:(id)comparator; ++ (void)finishInstallationToPath:(NSString *)installationPath withResult:(BOOL)result host:(SUHost *)host error:(NSError *)error delegate:(id)delegate; ++ (NSString *)updateFolder; + @end @protocol SUInstallerDelegate diff --git a/Sparkle/SUInstaller.m b/Sparkle/SUInstaller.m index 6a438b94..bc4f549b 100644 --- a/Sparkle/SUInstaller.m +++ b/Sparkle/SUInstaller.m @@ -117,19 +117,19 @@ static NSString* sUpdateFolder = nil; return isPackage ? nil : path; } -+ (void)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath delegate:(id)delegate synchronously:(BOOL)synchronously versionComparator:(id )comparator ++ (void)installFromUpdateFolder:(NSString *)inUpdateFolder overHost:(SUHost *)host installationPath:(NSString *)installationPath delegate:(id)delegate versionComparator:(id)comparator { BOOL isPackage = NO; - NSString *newAppDownloadPath = [self installSourcePathInUpdateFolder:inUpdateFolder forHost:host isPackage:&isPackage]; + NSString *newAppDownloadPath = [self installSourcePathInUpdateFolder:inUpdateFolder forHost:host isPackage:&isPackage]; - 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."}] delegate:delegate]; - } - else - { - [(isPackage ? [SUPackageInstaller class] : [SUPlainInstaller class]) performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host delegate:delegate synchronously:synchronously versionComparator:comparator]; - } + 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." }] delegate:delegate]; + } + else + { + [(isPackage ? [SUPackageInstaller class] : [SUPlainInstaller class])performInstallationToPath:installationPath fromPath:newAppDownloadPath host:host delegate:delegate versionComparator:comparator]; + } } + (void)mdimportInstallationPath:(NSString *)installationPath diff --git a/Sparkle/SUPackageInstaller.m b/Sparkle/SUPackageInstaller.m index 9e5a3527..fc25f955 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 delegate:(id)delegate synchronously:(BOOL)synchronously versionComparator:(id)__unused comparator ++ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host delegate:(id)delegate versionComparator:(id)__unused comparator { // Run installer using the "open" command to ensure it is launched in front of current application. // -W = wait until the app has quit. @@ -27,21 +27,15 @@ return; } - void (^performInstallation)() = ^void() { + dispatch_async(dispatch_get_global_queue(0, 0), ^{ NSTask *installer = [NSTask launchedTaskWithLaunchPath:command arguments:args]; [installer waitUntilExit]; // Known bug: if the installation fails or is canceled, Sparkle goes ahead and restarts, thinking everything is fine. - dispatch_async(dispatch_get_main_queue(), ^ { + dispatch_async(dispatch_get_main_queue(), ^{ [self finishInstallationToPath:installationPath withResult:YES host:host error:nil delegate:delegate]; }); - }; - - if (synchronously) { - performInstallation(); - } else { - dispatch_async(dispatch_get_global_queue(0, 0), performInstallation); - } + }); } @end diff --git a/Sparkle/SUPlainInstaller.h b/Sparkle/SUPlainInstaller.h index 414bbc5e..bb7827a6 100644 --- a/Sparkle/SUPlainInstaller.h +++ b/Sparkle/SUPlainInstaller.h @@ -20,7 +20,9 @@ @class SUHost; @interface SUPlainInstaller : SUInstaller -+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host delegate:(id)delegate synchronously:(BOOL)synchronously versionComparator:(id )comparator; + ++ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host delegate:(id)delegate versionComparator:(id)comparator; + @end #endif diff --git a/Sparkle/SUPlainInstaller.m b/Sparkle/SUPlainInstaller.m index 80dc54bc..36c4e861 100644 --- a/Sparkle/SUPlainInstaller.m +++ b/Sparkle/SUPlainInstaller.m @@ -13,7 +13,7 @@ @implementation SUPlainInstaller -+ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host delegate:(id)delegate synchronously:(BOOL)synchronously versionComparator:(id)comparator ++ (void)performInstallationToPath:(NSString *)installationPath fromPath:(NSString *)path host:(SUHost *)host delegate:(id)delegate versionComparator:(id)comparator { // Prevent malicious downgrades: #if !PERMIT_AUTOMATED_DOWNGRADES @@ -26,7 +26,7 @@ } #endif - void (^performInstallation)() = ^void() { + dispatch_async(dispatch_get_global_queue(0, 0), ^{ NSError *error = nil; NSString *oldPath = [host bundlePath]; NSString *tempName = [self temporaryNameForPath:[host installationPath]]; @@ -41,16 +41,10 @@ } } - dispatch_async(dispatch_get_main_queue(), ^ { + dispatch_async(dispatch_get_main_queue(), ^{ [self finishInstallationToPath:installationPath withResult:result host:host error:error delegate:delegate]; }); - }; - - if (synchronously) { - performInstallation(); - } else { - dispatch_async(dispatch_get_global_queue(0, 0), performInstallation); - } + }); } @end