Skip to content

Commit

Permalink
Add initial error handling to DownloadManager for permission errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Eitot committed Jul 9, 2023
1 parent c7f5ff6 commit 9b18b87
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions Vienna/Sources/Download window/DownloadManager.m
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,19 @@ - (void)URLSession:(NSURLSession *)session
didFinishDownloadingToURL:(NSURL *)location {
dispatch_sync(dispatch_get_main_queue(), ^{
DownloadItem *item = [self itemForSessionTask:downloadTask];
[NSFileManager.defaultManager moveItemAtURL:location
toURL:item.fileURL
error:nil];
item.state = DownloadStateCompleted;
NSError *error;
BOOL success = [NSFileManager.defaultManager moveItemAtURL:location
toURL:item.fileURL
error:&error];
if (success) {
item.state = DownloadStateCompleted;
} else {
item.state = DownloadStateFailed;
if (error.code == NSFileWriteNoPermissionError) {
// TODO: Implement error reporting
NSLog(@"%@", error.localizedDescription);
}
}
[self deliverNotificationForDownloadItem:item];
});
}
Expand Down

0 comments on commit 9b18b87

Please sign in to comment.