From 0cdbe32e88cbb15d7995464200dfe1367dddc993 Mon Sep 17 00:00:00 2001 From: Josh Ellis Date: Mon, 5 Oct 2020 09:13:59 +0100 Subject: [PATCH 1/2] Log error to device console if a download completes with error. --- Downloader.m | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Downloader.m b/Downloader.m index bf102688..a7d27630 100644 --- a/Downloader.m +++ b/Downloader.m @@ -133,7 +133,9 @@ - (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTas - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error { - if (error && error.code != NSURLErrorCancelled) { + if (error) { + NSLog(@"RNFS download: didCompleteWithError %@, %@", error, error.userInfo); + if(error.code != NSURLErrorCancelled){ _resumeData = error.userInfo[NSURLSessionDownloadTaskResumeData]; if (_resumeData != nil) { if (_params.resumableCallback) { @@ -142,6 +144,7 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didComp } else { _params.errorCallback(error); } + } } } From 136b4832a48e4104217a45ec42de91a3e4827e7f Mon Sep 17 00:00:00 2001 From: Josh Ellis Date: Mon, 5 Oct 2020 09:14:26 +0100 Subject: [PATCH 2/2] add manual flush & invalidation to avoid error 28 no space left on device --- Downloader.m | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Downloader.m b/Downloader.m index a7d27630..b17187d8 100644 --- a/Downloader.m +++ b/Downloader.m @@ -128,6 +128,14 @@ - (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTas NSLog(@"RNFS download: unable to move tempfile to destination. %@, %@", error, error.userInfo); } + // When numerous downloads are called the sessions are not always invalidated and cleared by iOS14. + // This leads to error 28 – no space left on device so we manually flush and invalidate to free up space + if(session != nil){ + [session flushWithCompletitonHandler:^{ + [session finishTasksAndInvalidate]; + }]; + } + return _params.completeCallback(_statusCode, _bytesWritten); }