Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-12187

remove and removeRecursively should be run in background threads

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • cordova-plugin-file
    • 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?

      Attachments

        Activity

          People

            Unassigned Unassigned
            lasse Lasse
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated: