download controller - delete existing file (if it exists) when re-downloading an existing rom.

This commit is contained in:
Kelvin Sherlock 2024-03-18 16:39:42 -04:00
parent 308b15277c
commit 45fe32893f
1 changed files with 4 additions and 1 deletions

View File

@ -610,13 +610,16 @@ static NSInteger TaskStatusCode(NSURLSessionTask *task) {
NSURL *dest = [_romFolder URLByAppendingPathComponent: [src lastPathComponent]];
NSError *error = nil;
/* just in case ... */
[fm removeItemAtURL: dest error: NULL];
[fm moveItemAtURL: location toURL: dest error: &error];
dispatch_async(dispatch_get_main_queue(), ^(void){
NSMutableDictionary *taskIndex = self->_taskIndex;
DownloadItem *item = [taskIndex objectForKey: task];
[item refresh: dest];
if (error) [item completeWithError: error];
else [item refresh: dest];
});
NSLog(@"%@", src);