Details
-
Improvement
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
-
iOS
Description
The File plugin methods remove and removeRecursively are not run in background threads, meaning they block the UI.
https://github.com/apache/cordova-plugin-file/blob/4.3.0/src/ios/CDVFile.m#L700-L747
Simply wrapping the functionality in runInBackground seems to work on iOS 8/9/10, e.g.
- (void)removeRecursively:(CDVInvokedUrlCommand*)command { // arguments CDVFilesystemURL* localURI = [self fileSystemURLforArg:command.arguments[0]]; [self.commandDelegate runInBackground:^ { CDVPluginResult* result = nil; if ([localURI.fullPath isEqualToString:@""]) { // error if try to remove top level (documents or tmp) dir result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageAsInt:NO_MODIFICATION_ALLOWED_ERR]; } else { NSObject<CDVFileSystem> *fs = [self filesystemForURL:localURI]; result = [fs recursiveRemoveFileAtURL:localURI]; } [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; }]; }
Is there a reason why remove and removeRecursively are not run in background threads?