mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-25 04:47:55 +00:00
More care to handling invalidation logic
This commit is contained in:
1 parent
d5cd64159c
commit
51e1e1c646
3 files changed
+36
-16
No files matched your search
Vendored
+1
-2
@@ -109,10 +109,9 @@
|
||||
[connection resume];
|
||||
|
||||
[connection.remoteObjectProxy startDownloadWithRequest:request completion:^(NSData * _Nullable appcastData, NSError * _Nullable error) {
|
||||
[connection invalidate];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
retrievedDownloadResult = YES;
|
||||
[connection invalidate];
|
||||
|
||||
if (appcastData == nil) {
|
||||
[self reportError:error];
|
||||
|
||||
Vendored
+9
-11
@@ -80,7 +80,8 @@
|
||||
|
||||
self.connection.invalidationHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (!retrievedDownloadResult) {
|
||||
SUDownloadDriver *strongSelf = weakSelf;
|
||||
if (!retrievedDownloadResult && strongSelf != nil) {
|
||||
SULog(@"Connection to update downloader was invalidated");
|
||||
|
||||
NSDictionary *userInfo =
|
||||
@@ -90,7 +91,7 @@
|
||||
|
||||
NSError *downloadError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:userInfo];
|
||||
|
||||
[weakSelf.delegate downloadDriverDidFailToDownloadUpdateWithError:downloadError];
|
||||
[strongSelf.delegate downloadDriverDidFailToDownloadUpdateWithError:downloadError];
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -99,6 +100,10 @@
|
||||
[self.connection.remoteObjectProxy startDownloadWithRequest:self.request bundleIdentifier:bundleIdentifier desiredFilename:desiredFilename completion:^(BOOL success, NSError * _Nullable error) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
retrievedDownloadResult = YES;
|
||||
SUDownloadDriver *strongSelf = weakSelf;
|
||||
if (strongSelf == nil) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!success) {
|
||||
NSURL *failingUrl = error.userInfo[NSURLErrorFailingURLErrorKey];
|
||||
@@ -115,16 +120,9 @@
|
||||
}
|
||||
|
||||
NSError *downloadError = [NSError errorWithDomain:SUSparkleErrorDomain code:SUDownloadError userInfo:userInfo];
|
||||
[self.delegate downloadDriverDidFailToDownloadUpdateWithError:downloadError];
|
||||
[strongSelf.delegate downloadDriverDidFailToDownloadUpdateWithError:downloadError];
|
||||
} else {
|
||||
// If this fails, then we must have already cleaned up / cancelled
|
||||
SUDownloadDriver *strongSelf = weakSelf;
|
||||
if (strongSelf.connection != nil) {
|
||||
[strongSelf.connection invalidate];
|
||||
strongSelf.connection = nil;
|
||||
|
||||
[strongSelf.delegate downloadDriverDidDownloadUpdate];
|
||||
}
|
||||
[strongSelf.delegate downloadDriverDidDownloadUpdate];
|
||||
}
|
||||
});
|
||||
}];
|
||||
|
||||
Vendored
+26
-3
@@ -391,10 +391,33 @@
|
||||
launcherConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUInstallerLauncherProtocol)];
|
||||
[launcherConnection resume];
|
||||
|
||||
[launcherConnection.remoteObjectProxy launchInstallerAtPath:relaunchToolPath withArguments:@[hostBundleIdentifier] completion:^(BOOL success) {
|
||||
[launcherConnection invalidate];
|
||||
|
||||
__block BOOL retrievedLaunchStatus = NO;
|
||||
|
||||
__weak NSXPCConnection *weakConnection = launcherConnection;
|
||||
launcherConnection.interruptionHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (!retrievedLaunchStatus) {
|
||||
[weakConnection invalidate];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
launcherConnection.invalidationHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (!retrievedLaunchStatus) {
|
||||
NSError *error =
|
||||
[NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey:SULocalizedString(@"An error occurred while connecting to the installer. Please try again later.", nil) }];
|
||||
|
||||
completionHandler(error);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
[launcherConnection.remoteObjectProxy launchInstallerAtPath:relaunchToolPath withArguments:@[hostBundleIdentifier] completion:^(BOOL success) {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
retrievedLaunchStatus = YES;
|
||||
[launcherConnection invalidate];
|
||||
|
||||
if (!success) {
|
||||
NSError *error =
|
||||
[NSError errorWithDomain:SUSparkleErrorDomain code:SUInstallationError userInfo:@{ NSLocalizedDescriptionKey:SULocalizedString(@"An error occurred while launching the installer. Please try again later.", nil) }];
|
||||
|
||||
Reference in new issue
Block a user