From 3c81d4d2ceecdb863623e0f0c0dd4b3fe903a52c Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Thu, 1 Oct 2020 13:11:13 -0400 Subject: [PATCH] tweak rom url, log download errors. --- Ample/DownloadWindowController.m | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Ample/DownloadWindowController.m b/Ample/DownloadWindowController.m index ecc6a63..7999cdd 100644 --- a/Ample/DownloadWindowController.m +++ b/Ample/DownloadWindowController.m @@ -108,7 +108,7 @@ enum { [self setCurrentCount: 0]; [self setTotalCount: [roms count]]; [self setErrorCount: 0]; - _sourceURL = [NSURL URLWithString: @"https://archive.org/download/mame0224_rom"]; // hardcoded.... + _sourceURL = [NSURL URLWithString: @"https://archive.org/download/mame225_rom"]; // hardcoded.... NSMutableArray *tmp = [NSMutableArray arrayWithCapacity: [roms count]]; @@ -278,15 +278,17 @@ enum { -(void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error { + if (error) NSLog(@"Download error: %@", error); + // not sure if strictly necessary but this happens in a background thread // and these are used in KVO binding. Also, main thread only // means no race conditions. dispatch_async(dispatch_get_main_queue(), ^(void){ - if (error) + if (error) { [self setErrorCount: self->_errorCount + 1]; - else + } else { [self setCurrentCount: self->_currentCount + 1]; - + } NSMutableDictionary *taskIndex = self->_taskIndex; DownloadItem *item = [taskIndex objectForKey: task]; [taskIndex removeObjectForKey: task]; @@ -307,7 +309,7 @@ enum { - (void)URLSession:(NSURLSession *)session downloadTask:(nonnull NSURLSessionDownloadTask *)task didFinishDownloadingToURL:(nonnull NSURL *)location { - +// NSLog(@"%@", task); // need to move to the destination directory... // file deleted after this function returns, so can't move asynchronously. NSFileManager *fm = [NSFileManager defaultManager];