diff --git a/Sparkle/SUBasicUpdateDriver.m b/Sparkle/SUBasicUpdateDriver.m index 42d6e185..927f3eae 100644 --- a/Sparkle/SUBasicUpdateDriver.m +++ b/Sparkle/SUBasicUpdateDriver.m @@ -577,6 +577,9 @@ } } + //Set relaunching flag. + [self.host setBool:YES forUserDefaultsKey:SUUpdateRelaunchingMarkerKey]; + [NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:@[[self.host bundlePath], pathToRelaunch, [NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]], diff --git a/Sparkle/SUConstants.h b/Sparkle/SUConstants.h index 9f377e68..5ff8fb01 100644 --- a/Sparkle/SUConstants.h +++ b/Sparkle/SUConstants.h @@ -35,6 +35,7 @@ extern NSString *const SUTechnicalErrorInformationKey; extern NSString *const SUFeedURLKey; extern NSString *const SUHasLaunchedBeforeKey; +extern NSString *const SUUpdateRelaunchingMarkerKey; extern NSString *const SUShowReleaseNotesKey; extern NSString *const SUSkippedVersionKey; extern NSString *const SUScheduledCheckIntervalKey; diff --git a/Sparkle/SUConstants.m b/Sparkle/SUConstants.m index 955a9c9e..fc4e8e67 100644 --- a/Sparkle/SUConstants.m +++ b/Sparkle/SUConstants.m @@ -26,6 +26,7 @@ NSString *const SUAppcastAttributeValueMacOS = @"macos"; NSString *const SUTechnicalErrorInformationKey = @"SUTechnicalErrorInformation"; NSString *const SUHasLaunchedBeforeKey = @"SUHasLaunchedBefore"; +NSString *const SUUpdateRelaunchingMarkerKey = @"SUUpdateRelaunchingMarker"; NSString *const SUFeedURLKey = @"SUFeedURL"; NSString *const SUShowReleaseNotesKey = @"SUShowReleaseNotes"; NSString *const SUSkippedVersionKey = @"SUSkippedVersion"; diff --git a/Sparkle/SUHost.h b/Sparkle/SUHost.h old mode 100644 new mode 100755 diff --git a/Sparkle/SUHost.m b/Sparkle/SUHost.m old mode 100644 new mode 100755 diff --git a/Sparkle/SUUpdater.m b/Sparkle/SUUpdater.m index 9e732136..b20d9499 100644 --- a/Sparkle/SUUpdater.m +++ b/Sparkle/SUUpdater.m @@ -208,6 +208,14 @@ static NSString *const SUUpdaterDefaultsObservationContext = @"SUUpdaterDefaults if (!hasLaunchedBefore) { [self.host setBool:YES forUserDefaultsKey:SUHasLaunchedBeforeKey]; } + // Relanching from app update? + else if ([self.host boolForUserDefaultsKey:SUUpdateRelaunchingMarkerKey]) { + if ([self.delegate respondsToSelector:@selector(updaterDidRelaunchApplication:)]) { + [self.delegate updaterDidRelaunchApplication:self]; + } + //Reset flag back to NO. + [self.host setBool:NO forUserDefaultsKey:SUUpdateRelaunchingMarkerKey]; + } if (shouldPrompt) { NSArray *> *profileInfo = [SUSystemProfiler systemProfileArrayForHost:self.host]; diff --git a/Sparkle/SUUpdaterDelegate.h b/Sparkle/SUUpdaterDelegate.h index 39249ac4..dbc14024 100644 --- a/Sparkle/SUUpdaterDelegate.h +++ b/Sparkle/SUUpdaterDelegate.h @@ -192,6 +192,13 @@ SU_EXPORT extern NSString *const SUUpdaterAppcastNotificationKey; */ - (void)updaterWillRelaunchApplication:(SUUpdater *)updater; +/*! + Called immediately after relaunching. SUUpdater delegate must be set before applicationDidFinishLaunching: to catch this event. + + \param updater The SUUpdater instance. + */ +- (void)updaterDidRelaunchApplication:(SUUpdater *)updater; + /*! Returns an object that compares version numbers to determine their arithmetic relation to each other.