Skip to content

Commit

Permalink
fix(ios): no space left on device
Browse files Browse the repository at this point in the history
  • Loading branch information
ltm committed Sep 23, 2022
1 parent 3afcf14 commit fc254fe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
Changelog
======
## 5.5.3
* Fixed iOS "no space left on device"

## 5.5.2
* Fixed iOS error 28 – no space left on device

Expand Down
11 changes: 1 addition & 10 deletions src/ios/IonicCordovaCommon.m
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@ - (void) downloadFile:(CDVInvokedUrlCommand*)command {
NSLog(@"Got downloadFile: %@", options);

NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:urlStr]];
NSURLSession *urlSession = [NSURLSession sessionWithConfiguration:[NSURLSessionConfiguration defaultSessionConfiguration]];
[[urlSession dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"Download Error:%@",error.description);
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString: [error localizedDescription]] callbackId:command.callbackId];
Expand All @@ -90,14 +89,6 @@ - (void) downloadFile:(CDVInvokedUrlCommand*)command {
NSLog(@"File is saved to %@", target);
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK] callbackId:command.callbackId];
}

// 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(urlSession != nil) {
[urlSession flushWithCompletionHandler:^{
[urlSession finishTasksAndInvalidate];
}];
}
}] resume];
}

Expand Down

0 comments on commit fc254fe

Please sign in to comment.