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

webworks commit: [CB-981] Return FILE_NOT_FOUND error for bad file name.

Updated Branches:
  refs/heads/master a5538a1b6 -> b8a012de8


[CB-981] Return FILE_NOT_FOUND error for bad file name.


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

Branch: refs/heads/master
Commit: b8a012de86a7600fe2a775794cfe288a69555827
Parents: a5538a1
Author: Drew Walters <de...@apache.org>
Authored: Thu Jun 28 14:48:29 2012 -0500
Committer: Drew Walters <de...@apache.org>
Committed: Thu Jun 28 14:48:29 2012 -0500

----------------------------------------------------------------------
 .../src/org/apache/cordova/http/FileTransfer.java  |   15 +++++++++++----
 .../src/org/apache/cordova/http/FileUploader.java  |    2 ++
 2 files changed, 13 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/b8a012de/framework/ext/src/org/apache/cordova/http/FileTransfer.java
----------------------------------------------------------------------
diff --git a/framework/ext/src/org/apache/cordova/http/FileTransfer.java b/framework/ext/src/org/apache/cordova/http/FileTransfer.java
index 14ba854..0312707 100644
--- a/framework/ext/src/org/apache/cordova/http/FileTransfer.java
+++ b/framework/ext/src/org/apache/cordova/http/FileTransfer.java
@@ -332,12 +332,19 @@ public class FileTransfer extends Plugin {
         }
 
         try {
-            // Create any directories in the path that do not already exist.
-            createSubDirs(path);
+            try {
+                // Create any directories in the path that do not already exist.
+                createSubDirs(path);
 
-            // Open connection to the target file.
-            fileConn = (FileConnection) Connector.open(target,
+                // Open connection to the target file.
+                fileConn = (FileConnection) Connector.open(target,
                     Connector.READ_WRITE);
+            } catch (IOException e) {
+                Logger.log(LOG_TAG + "Failed to open target file: " + target);
+                JSONObject error = createFileTransferError(FILE_NOT_FOUND_ERR, source,
+                        target, httpConn);
+                return new PluginResult(PluginResult.Status.IO_EXCEPTION, error);
+            }
 
             // Create the target file if it doesn't exist, otherwise truncate.
             if (!fileConn.exists()) {

http://git-wip-us.apache.org/repos/asf/incubator-cordova-blackberry-webworks/blob/b8a012de/framework/ext/src/org/apache/cordova/http/FileUploader.java
----------------------------------------------------------------------
diff --git a/framework/ext/src/org/apache/cordova/http/FileUploader.java b/framework/ext/src/org/apache/cordova/http/FileUploader.java
index 5be5483..af548e3 100644
--- a/framework/ext/src/org/apache/cordova/http/FileUploader.java
+++ b/framework/ext/src/org/apache/cordova/http/FileUploader.java
@@ -84,6 +84,8 @@ public class FileUploader {
             } catch (ClassCastException e) {
                 // in case something really funky gets passed in
                 throw new IllegalArgumentException("Invalid file path");
+            } catch (IOException e) {
+                throw new FileNotFoundException("Failed to open source file: " + filePath);
             }
             if (!fconn.exists()) {
                 throw new FileNotFoundException(filePath + " not found");