From 223d08626df36c0f386af3fe609d0a36c450d6d9 Mon Sep 17 00:00:00 2001 From: torrmal Date: Wed, 26 Mar 2014 11:58:26 -0400 Subject: [PATCH] [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. --- src/ios/CDVFileTransfer.m | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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