From 423d2882908b224aa4036b99f7f659ce4559408c Mon Sep 17 00:00:00 2001 From: Zorg Date: Sun, 14 Aug 2016 21:48:16 -0400 Subject: [PATCH] Add some defense and comment about relaunching the new app --- .../InstallerProgress/InstallerProgressAppController.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Sparkle/InstallerProgress/InstallerProgressAppController.m b/Sparkle/InstallerProgress/InstallerProgressAppController.m index 9352f575..03d34fa5 100644 --- a/Sparkle/InstallerProgress/InstallerProgressAppController.m +++ b/Sparkle/InstallerProgress/InstallerProgressAppController.m @@ -168,6 +168,7 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.3; if (relaunchBundlePath != nil && !self.willTerminate) { NSBundle *relaunchBundle = [NSBundle bundleWithPath:relaunchBundlePath]; if (relaunchBundle == nil) { + SULog(@"Error: Encountered invalid path for waiting termination: %@", relaunchBundlePath); [self cleanupAndExitWithStatus:EXIT_FAILURE]; } @@ -191,12 +192,21 @@ static const NSTimeInterval SUTerminationTimeDelay = 0.3; } // The pathToRelaunch passed to here is not necessarily the same as the one passed in -registerRelaunchBundlePath:reply: if the developer uses SPARKLE_NORMALIZE_INSTALLED_APPLICATION_NAME +// Note the installer won't tell us to launch an application unless it was already running before - (void)relaunchPath:(NSString *)pathToRelaunch { dispatch_async(dispatch_get_main_queue(), ^{ if (!self.willTerminate) { // We only launch applications, but I'm not sure how reliable -launchApplicationAtURL:options:config: is so we're not using it // Eg: http://www.openradar.me/10952677 + + // We should at least make sure we're opening a bundle however + NSBundle *relaunchBundle = [NSBundle bundleWithPath:pathToRelaunch]; + if (relaunchBundle == nil) { + SULog(@"Error: Encountered invalid path to relaunch: %@", pathToRelaunch); + [self cleanupAndExitWithStatus:EXIT_FAILURE]; + } + if (![[NSWorkspace sharedWorkspace] openFile:pathToRelaunch]) { SULog(@"Error: Failed to relaunch bundle at %@", pathToRelaunch); }