You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sh...@apache.org on 2012/04/10 21:37:49 UTC

[2/2] ios commit: Tweak CB-475 - download callback differentiation on error (via @marcuswu)

Tweak CB-475 - download callback differentiation on error (via @marcuswu)


Project: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/commit/bef0d75a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/tree/bef0d75a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/diff/bef0d75a

Branch: refs/heads/master
Commit: bef0d75a1759425c1f2565230faca387a0ba5220
Parents: 0bb76ed
Author: Shazron Abdullah <sh...@apache.org>
Authored: Tue Apr 10 12:35:29 2012 -0700
Committer: Shazron Abdullah <sh...@apache.org>
Committed: Tue Apr 10 12:35:29 2012 -0700

----------------------------------------------------------------------
 CordovaLib/Classes/CDVFileTransfer.m |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-ios/blob/bef0d75a/CordovaLib/Classes/CDVFileTransfer.m
----------------------------------------------------------------------
diff --git a/CordovaLib/Classes/CDVFileTransfer.m b/CordovaLib/Classes/CDVFileTransfer.m
index 98df466..5b7ff42 100644
--- a/CordovaLib/Classes/CDVFileTransfer.m
+++ b/CordovaLib/Classes/CDVFileTransfer.m
@@ -232,6 +232,7 @@
     NSError *error;
     NSString *parentPath;
     BOOL bDirRequest = NO;
+    BOOL errored = NO;
     CDVFile * file;
     
     if(self.direction == CDV_TRANSFER_UPLOAD)
@@ -276,12 +277,19 @@
             @catch (id exception) {
                 // jump back to main thread
                 result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: [command createFileTransferError:[NSString stringWithFormat:@"%d", FILE_NOT_FOUND_ERR] AndSource:source AndTarget:target]];
+                errored = YES;
             }
         } else {
             result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary: [command createFileTransferError:[NSString stringWithFormat:@"%d", CONNECTION_ERR] AndSource:source AndTarget:target]];
+            errored = YES;
         }
     }
-    [self.command writeJavascript:[result toSuccessCallbackString: callbackId]];
+    
+    if(!errored) {
+        [self.command writeJavascript:[result toSuccessCallbackString: callbackId]];
+    } else {
+        [self.command writeJavascript:[result toErrorCallbackString: callbackId]];
+    }    
     [uploadResponse release];
 }