Skip to content

Commit

Permalink
Add optional updaterDidRelaunchApplication: method on SUUpdaterDelega…
Browse files Browse the repository at this point in the history
…te (sparkle-project#1115)

* Added updaterDidRelaunchApplication: delegate method.

* Removed isUpdaterRelaunching property.

* Revert SUHost.
  • Loading branch information
AppTyrant authored and kornelski committed Aug 7, 2017
1 parent 43b4472 commit 7c8ff2b
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions Sparkle/SUBasicUpdateDriver.m
Expand Up @@ -577,6 +577,9 @@ - (void)installWithToolAndRelaunch:(BOOL)relaunch displayingUserInterface:(BOOL)
}
}

//Set relaunching flag.
[self.host setBool:YES forUserDefaultsKey:SUUpdateRelaunchingMarkerKey];

[NSTask launchedTaskWithLaunchPath:relaunchToolPath arguments:@[[self.host bundlePath],
pathToRelaunch,
[NSString stringWithFormat:@"%d", [[NSProcessInfo processInfo] processIdentifier]],
Expand Down
1 change: 1 addition & 0 deletions Sparkle/SUConstants.h
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions Sparkle/SUConstants.m
Expand Up @@ -26,6 +26,7 @@
NSString *const SUTechnicalErrorInformationKey = @"SUTechnicalErrorInformation";

NSString *const SUHasLaunchedBeforeKey = @"SUHasLaunchedBefore";
NSString *const SUUpdateRelaunchingMarkerKey = @"SUUpdateRelaunchingMarker";
NSString *const SUFeedURLKey = @"SUFeedURL";
NSString *const SUShowReleaseNotesKey = @"SUShowReleaseNotes";
NSString *const SUSkippedVersionKey = @"SUSkippedVersion";
Expand Down
Empty file modified Sparkle/SUHost.h 100644 → 100755
Empty file.
Empty file modified Sparkle/SUHost.m 100644 → 100755
Empty file.
8 changes: 8 additions & 0 deletions Sparkle/SUUpdater.m
Expand Up @@ -208,6 +208,14 @@ - (void)startUpdateCycle
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<NSDictionary<NSString *, NSString *> *> *profileInfo = [SUSystemProfiler systemProfileArrayForHost:self.host];
Expand Down
7 changes: 7 additions & 0 deletions Sparkle/SUUpdaterDelegate.h
Expand Up @@ -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.
Expand Down

0 comments on commit 7c8ff2b

Please sign in to comment.