diff --git a/PersistentDownloader/SUPersistentDownloader.m b/PersistentDownloader/SUPersistentDownloader.m index 6fd154b2..4453e6e5 100644 --- a/PersistentDownloader/SUPersistentDownloader.m +++ b/PersistentDownloader/SUPersistentDownloader.m @@ -77,14 +77,6 @@ static NSString *SUPersistentDownloadingReason = @"Downloading persistent file"; self.delegate = nil; } -- (void)cleanupWithCompletion:(void (^)(void))completionBlock -{ - dispatch_async(dispatch_get_main_queue(), ^{ - [self cleanup]; - completionBlock(); - }); -} - - (void)download:(NSURLDownload *)__unused d decideDestinationWithSuggestedFilename:(NSString *)name { // Remove our old caches path so we don't start accumulating files in there diff --git a/PersistentDownloader/SUPersistentDownloaderProtocol.h b/PersistentDownloader/SUPersistentDownloaderProtocol.h index 2bd159db..ae520375 100644 --- a/PersistentDownloader/SUPersistentDownloaderProtocol.h +++ b/PersistentDownloader/SUPersistentDownloaderProtocol.h @@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)startDownloadWithRequest:(SPUURLRequest *)request bundleIdentifier:(NSString *)bundleIdentifier desiredFilename:(NSString *)desiredFilename; -- (void)cleanupWithCompletion:(void (^)(void))completionBlock; +- (void)cleanup; @end diff --git a/Sparkle/SUDownloadDriver.m b/Sparkle/SUDownloadDriver.m index 1c17fa0b..70529fca 100644 --- a/Sparkle/SUDownloadDriver.m +++ b/Sparkle/SUDownloadDriver.m @@ -123,22 +123,16 @@ - (void)cleanup { - // It's very crucial to wait until they are done with completion before invalidating our XPC connection (if there is one) - // Otherwise we can run into some unfortunate crashes - // Edit: I think this was an issue because -dealloc was implemented to invoke this method. I have since removed -dealloc - // Will have to test around with this later self.cleaningUp = YES; - [self.downloader cleanupWithCompletion:^{ - dispatch_async(dispatch_get_main_queue(), ^{ - if (self.connection != nil) { - [self.connection invalidate]; - self.connection = nil; - } - self.downloadName = nil; - self.downloader = nil; - }); - }]; + [self.downloader cleanup]; + + if (self.connection != nil) { + [self.connection invalidate]; + self.connection = nil; + } + self.downloadName = nil; + self.downloader = nil; } - (void)downloaderDidFinishDownloading