File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -128,12 +128,22 @@ - (void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTas
128128 NSLog (@" RNFS download: unable to move tempfile to destination. %@ , %@ " , error, error.userInfo );
129129 }
130130
131+ // When numerous downloads are called the sessions are not always invalidated and cleared by iOS14.
132+ // This leads to error 28 – no space left on device so we manually flush and invalidate to free up space
133+ if (session != nil ){
134+ [session flushWithCompletionHandler: ^{
135+ [session finishTasksAndInvalidate ];
136+ }];
137+ }
138+
131139 return _params.completeCallback (_statusCode, _bytesWritten);
132140}
133141
134142- (void )URLSession : (NSURLSession *)session task : (NSURLSessionTask *)task didCompleteWithError : (NSError *)error
135143{
136- if (error && error.code != NSURLErrorCancelled) {
144+ if (error) {
145+ NSLog (@" RNFS download: didCompleteWithError %@ , %@ " , error, error.userInfo );
146+ if (error.code != NSURLErrorCancelled) {
137147 _resumeData = error.userInfo [NSURLSessionDownloadTaskResumeData ];
138148 if (_resumeData != nil ) {
139149 if (_params.resumableCallback ) {
@@ -142,6 +152,7 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didComp
142152 } else {
143153 _params.errorCallback (error);
144154 }
155+ }
145156 }
146157}
147158
You can’t perform that action at this time.
0 commit comments