Update is no longer cancelable after installation begins

This commit is contained in:
Zorg committed 2016-07-26 19:25:49 -04:00
1 parent 0ca688073b
commit f9e2609fa1
2 files changed
+21 -47

No files matched your search

+8 -25
View File
@@ -498,9 +498,14 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
if (performedSecondStage) {
self.performedStage2Installation = YES;
}
void (^cleanupAndExit)(void) = ^{
dispatch_async(dispatch_get_main_queue(), ^{
uint8_t targetTerminated = (uint8_t)self.terminationListener.terminated;
NSData *sendData = [NSData dataWithBytes:&targetTerminated length:sizeof(targetTerminated)];
[self.communicator handleMessageWithIdentifier:SUInstallationFinishedStage2 data:sendData];
});
} else {
SULog(@"Error: Failed to resume installer on stage 2 with error: %@", secondStageError);
[self.installer cleanup];
self.installer = nil;
@@ -508,28 +513,6 @@ static const NSTimeInterval SUDisplayProgressTimeDelay = 0.7;
dispatch_async(dispatch_get_main_queue(), ^{
[self cleanupAndExitWithStatus:EXIT_FAILURE];
});
};
// Let the other end know we canceled so they can fail gracefully without disturbing the user
BOOL installationCanceled = (!performedSecondStage && secondStageError.code == SUInstallationCanceledError);
if (performedSecondStage || installationCanceled) {
dispatch_async(dispatch_get_main_queue(), ^{
uint8_t canceled = (uint8_t)installationCanceled;
uint8_t targetTerminated = (uint8_t)self.terminationListener.terminated;
uint8_t sendInfo[] = {canceled, targetTerminated};
NSData *sendData = [NSData dataWithBytes:sendInfo length:sizeof(sendInfo)];
[self.communicator handleMessageWithIdentifier:SUInstallationFinishedStage2 data:sendData];
if (installationCanceled) {
cleanupAndExit();
}
});
}
if (!performedSecondStage && !installationCanceled) {
cleanupAndExit();
}
}
+13 -22
View File
@@ -263,30 +263,21 @@
} else if (identifier == SUInstallationFinishedStage2) {
self.currentStage = identifier;
BOOL canceledInstallation = NO;
if (data.length >= sizeof(uint8_t)) {
canceledInstallation = (*(const uint8_t *)data.bytes == 0x1);
if (!self.startedInstalling) {
// It's possible we can start from resuming to stage 2 rather than doing stage 1 again, so we should notify to start installing if we haven't done so already
self.startedInstalling = YES;
[self.delegate installerDidStartInstalling];
}
if (canceledInstallation) {
[self.delegate installerIsRequestingAbortInstallWithError:nil];
} else {
if (!self.startedInstalling) {
// It's possible we can start from resuming to stage 2 rather than doing stage 1 again, so we should notify to start installing if we haven't done so already
self.startedInstalling = YES;
[self.delegate installerDidStartInstalling];
}
BOOL hasTargetTerminated = NO;
if (data.length >= sizeof(uint8_t) * 2) {
hasTargetTerminated = (BOOL)*((const uint8_t *)data.bytes + 1);
}
[self.delegate installerWillFinishInstallationAndRelaunch:self.willRelaunch];
if (!hasTargetTerminated) {
[self.delegate installerIsRequestingAppTermination];
}
BOOL hasTargetTerminated = NO;
if (data.length >= sizeof(uint8_t)) {
hasTargetTerminated = (BOOL)*((const uint8_t *)data.bytes);
}
[self.delegate installerWillFinishInstallationAndRelaunch:self.willRelaunch];
if (!hasTargetTerminated) {
[self.delegate installerIsRequestingAppTermination];
}
} else if (identifier == SUInstallationFinishedStage3) {
self.currentStage = identifier;