Post relaunch notification only if we are relaunching

This commit is contained in:
Zorg committed 2016-05-01 11:54:23 -04:00
1 parent 981f67e8b1
commit c0a148f5ff
3 files changed
+12 -7

No files matched your search

+6 -5
View File
@@ -213,16 +213,17 @@
}
}
- (void)installerWillFinishInstallation
- (void)installerWillFinishInstallationAndRelaunch:(BOOL)relaunch
{
if ([self.updaterDelegate respondsToSelector:@selector(updater:willInstallUpdate:)]) {
[self.updaterDelegate updater:self.updater willInstallUpdate:self.updateItem];
}
#warning should only notify if we are really about to restart the target...
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
if ([self.updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)]) {
[self.updaterDelegate updaterWillRelaunchApplication:self.updater];
if (relaunch) {
[[NSNotificationCenter defaultCenter] postNotificationName:SUUpdaterWillRestartNotification object:self];
if ([self.updaterDelegate respondsToSelector:@selector(updaterWillRelaunchApplication:)]) {
[self.updaterDelegate updaterWillRelaunchApplication:self.updater];
}
}
}
+1 -1
View File
@@ -19,7 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
- (void)installerDidExtractUpdateWithProgress:(double)progress;
- (void)installerDidFinishPreparationAndWillInstallImmediately:(BOOL)willInstallImmediately silently:(BOOL)willInstallSilently;
- (void)installerIsRequestingAppTermination;
- (void)installerWillFinishInstallation;
- (void)installerWillFinishInstallationAndRelaunch:(BOOL)relaunch;
- (void)installerDidFinishInstallation;
- (void)installerIsRequestingAbortInstallWithError:(nullable NSError *)error;
+5 -1
View File
@@ -43,6 +43,7 @@
@property (nonatomic) BOOL postponedOnce;
@property (nonatomic, weak, readonly) id updater;
@property (nonatomic, weak, readonly) id<SUUpdaterDelegate> updaterDelegate;
@property (nonatomic) BOOL willRelaunch;
@property (nonatomic) SUAppcastItem *updateItem;
@property (nonatomic, copy) NSString *downloadName;
@@ -63,6 +64,7 @@
@synthesize postponedOnce = _postponedOnce;
@synthesize updater = _updater;
@synthesize updaterDelegate = _updaterDelegate;
@synthesize willRelaunch = _willRelaunch;
@synthesize updateItem = _updateItem;
@synthesize downloadName = _downloadName;
@synthesize temporaryDirectory = _temporaryDirectory;
@@ -351,7 +353,7 @@
[self.remotePort invalidate];
self.remotePort = nil;
[self.delegate installerWillFinishInstallation];
[self.delegate installerWillFinishInstallationAndRelaunch:self.willRelaunch];
if (!hasTargetTerminated) {
[self.delegate installerIsRequestingAppTermination];
@@ -567,6 +569,8 @@
// For resumability, we'll assume we are far enough for the installation to continue
strongSelf.currentStage = SUInstallationFinishedStage1;
strongSelf.willRelaunch = relaunch;
uint8_t response[2] = {(uint8_t)relaunch, (uint8_t)showUI};
NSData *responseData = [NSData dataWithBytes:response length:sizeof(response)];