Skip to content

Commit f5ff3d2

Browse files
committed
enhancement from issue 938
itinance#938
1 parent f2f8f4a commit f5ff3d2

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Downloader.m

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,14 @@ - (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 flushWithCompletitonHandler:^{
135+
[session finishTasksAndInvalidate];
136+
}];
137+
}
138+
131139
return _params.completeCallback(_statusCode, _bytesWritten);
132140
}
133141

Uploader.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ - (void)uploadFiles:(RNFSUploadParams*)params
106106
NSURLSession *session = [NSURLSession sessionWithConfiguration:sessionConfiguration delegate:(id)self delegateQueue:[NSOperationQueue mainQueue]];
107107
_task = [session dataTaskWithRequest:req completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
108108
NSString * str = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
109+
// When numerous downloads are called the sessions are not always invalidated and cleared by iOS14.
110+
// This leads to error 28 – no space left on device so we manually flush and invalidate to free up space
111+
if(session != nil){
112+
[session flushWithCompletitonHandler:^{
113+
[session finishTasksAndInvalidate];
114+
}];
115+
}
109116
return self->_params.completeCallback(str, response);
110117
}];
111118
[_task resume];

0 commit comments

Comments
 (0)