Lasse created CB-12187:
--------------------------
Summary: remove and removeRecursively should be run in background
threads
Key: CB-12187
URL: https://issues.apache.org/jira/browse/CB-12187
Project: Apache Cordova
Issue Type: Improvement
Components: iOS, Plugin File
Environment: iOS
Reporter: Lasse
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.
{noformat}
- (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];
}];
}
{noformat}
Is there a reason why remove and removeRecursively are not run in background
threads?
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]