diff --git a/Sparkle/SPUCoreBasedUpdateDriver.m b/Sparkle/SPUCoreBasedUpdateDriver.m index 34c6f06a..563a136a 100644 --- a/Sparkle/SPUCoreBasedUpdateDriver.m +++ b/Sparkle/SPUCoreBasedUpdateDriver.m @@ -198,9 +198,13 @@ - (void)clearDownloadedUpdate { id downloadedUpdateObject = (_resumableUpdate != nil) ? _resumableUpdate : _downloadedUpdateForRemoval; - assert(downloadedUpdateObject != nil); - - if (downloadedUpdateObject != nil && [downloadedUpdateObject isKindOfClass:[SPUDownloadedUpdate class]]) { + + if (downloadedUpdateObject == nil) { + SULog(SULogLevelError, @"Warning: clearDownloadedUpdate called but no downloaded update is tracked"); + return; + } + + if ([downloadedUpdateObject isKindOfClass:[SPUDownloadedUpdate class]]) { if (_downloadDriver == nil) { _downloadDriver = [[SPUDownloadDriver alloc] initWithHost:_host]; } diff --git a/Sparkle/SPUInstallerDriver.m b/Sparkle/SPUInstallerDriver.m index 323240f7..d780ee3b 100644 --- a/Sparkle/SPUInstallerDriver.m +++ b/Sparkle/SPUInstallerDriver.m @@ -487,18 +487,22 @@ self->_systemDomain = systemDomain; [self setUpConnection]; [self sendInstallationData]; - + + // Complete immediately so the caller can set up state (e.g., _downloadedUpdateForRemoval) + // before installer messages arrive on the main queue. + // Previously, completionHandler was called inside the probe callback, which meant + // installer messages (SPUExtractionStarted, SPUArchiveExtractionFailed) could be + // processed before the completion handler fired, leaving _downloadedUpdateForRemoval + // unset and causing an assertion crash in clearDownloadedUpdate. + completionHandler(nil); + // Send a probe/ping to the status service, which should boost/prioritize its startup if (hostBundleIdentifier != nil) { [SPUProbeInstallStatus probeInstallerInProgressForHostBundleIdentifier:hostBundleIdentifier completion:^(BOOL stausServiceIsRunning) { if (!stausServiceIsRunning) { SULog(SULogLevelError, @"Error: failed to probe status service for %@ from the framework", hostBundleIdentifier); } - - completionHandler(nil); }]; - } else { - completionHandler(nil); } break;