[ 
https://issues.apache.org/jira/browse/CB-12187?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Shazron Abdullah updated CB-12187:
----------------------------------
    Component/s:     (was: iOS)

> 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: 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.15#6346)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to