mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-26 04:57:54 +00:00
Add error handling cleanup to Appcast Downloader connection
This commit is contained in:
1 parent
92e5c30c0d
commit
0b19d8d7fd
1 file changed
+30
Vendored
+30
@@ -78,12 +78,42 @@
|
||||
|
||||
NSXPCConnection *connection = [[NSXPCConnection alloc] initWithServiceName:@"org.sparkle-project.AppcastDownloader"];
|
||||
connection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(SUAppcastDownloaderProtocol)];
|
||||
|
||||
__block BOOL retrievedDownloadResult = NO;
|
||||
|
||||
__weak NSXPCConnection *weakConnection = connection;
|
||||
connection.interruptionHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (!retrievedDownloadResult) {
|
||||
[weakConnection invalidate];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
connection.invalidationHandler = ^{
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
if (!retrievedDownloadResult) {
|
||||
SULog(@"Appcast Downloader connection was invalidated");
|
||||
|
||||
NSDictionary *userInfo = [NSDictionary
|
||||
dictionaryWithObject: SULocalizedString(@"An error occurred while downloading the update feed.", nil)
|
||||
forKey: NSLocalizedDescriptionKey];
|
||||
|
||||
[self reportError:[NSError errorWithDomain:SUSparkleErrorDomain
|
||||
code:SUDownloadError
|
||||
userInfo:userInfo]];
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
[connection resume];
|
||||
|
||||
[connection.remoteObjectProxy startDownloadWithRequest:request completion:^(NSData * _Nullable appcastData, NSError * _Nullable error) {
|
||||
[connection invalidate];
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
retrievedDownloadResult = YES;
|
||||
|
||||
if (appcastData == nil) {
|
||||
[self reportError:error];
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user