You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by ia...@apache.org on 2014/04/23 20:57:09 UTC

[06/11] git commit: [CB-5175] CDVFileTransfer asynchronous download (Fixes #24)

[CB-5175] CDVFileTransfer asynchronous download (Fixes #24)

Since download can take time, for it to be non-blocking, moved the call to a separate thread.


Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/commit/223d0862
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/223d0862
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/223d0862

Branch: refs/heads/master
Commit: 223d08626df36c0f386af3fe609d0a36c450d6d9
Parents: 449df55
Author: torrmal <jo...@gmail.com>
Authored: Wed Mar 26 11:58:26 2014 -0400
Committer: Ian Clelland <ic...@chromium.org>
Committed: Thu Mar 27 13:21:26 2014 -0400

----------------------------------------------------------------------
 src/ios/CDVFileTransfer.m | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/223d0862/src/ios/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/src/ios/CDVFileTransfer.m b/src/ios/CDVFileTransfer.m
index 3753993..d87bb94 100644
--- a/src/ios/CDVFileTransfer.m
+++ b/src/ios/CDVFileTransfer.m
@@ -430,8 +430,12 @@ static CFIndex WriteDataToStream(NSData* data, CFWriteStreamRef stream)
     @synchronized (activeTransfers) {
         activeTransfers[delegate.objectId] = delegate;
     }
-
-    [delegate.connection start];
+    // Downloads can take time
+    // sending this to a new thread calling the download_async method
+    dispatch_async(
+                   dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL),
+                   ^(void) { [delegate.connection start];}
+                   );
 }
 
 - (NSMutableDictionary*)createFileTransferError:(int)code AndSource:(NSString*)source AndTarget:(NSString*)target