cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i..@apache.org
Subject git commit: CB-6050: Use instance method on actual file plugin object to get FileEntry to return on download
Date Tue, 18 Feb 2014 20:25:54 GMT
Repository: cordova-plugin-file-transfer
Updated Branches:
  refs/heads/dev 31ac00d3a -> 35f80e42e


CB-6050: Use instance method on actual file plugin object to get FileEntry to return on download


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/35f80e42
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/35f80e42
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/35f80e42

Branch: refs/heads/dev
Commit: 35f80e42ec0a0343022bffa88b1cbd2e68f0fc3f
Parents: 31ac00d
Author: Ian Clelland <iclelland@chromium.org>
Authored: Tue Feb 18 15:25:01 2014 -0500
Committer: Ian Clelland <iclelland@chromium.org>
Committed: Tue Feb 18 15:25:01 2014 -0500

----------------------------------------------------------------------
 plugin.xml                    |  2 +-
 src/android/FileTransfer.java | 16 ++++++++++++++--
 2 files changed, 15 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/35f80e42/plugin.xml
----------------------------------------------------------------------
diff --git a/plugin.xml b/plugin.xml
index a1a9ebd..d93cdac 100644
--- a/plugin.xml
+++ b/plugin.xml
@@ -11,7 +11,7 @@
     <issue>https://issues.apache.org/jira/browse/CB/component/12320650</issue>
 
     <!-- dependency id="org.apache.cordova.file@1" /-->
-    <dependency id="org.apache.cordova.file" />
+    <dependency id="org.apache.cordova.file" version="1.0.1" />
 
     <js-module src="www/FileTransferError.js" name="FileTransferError">
         <clobbers target="window.FileTransferError" />

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/35f80e42/src/android/FileTransfer.java
----------------------------------------------------------------------
diff --git a/src/android/FileTransfer.java b/src/android/FileTransfer.java
index 7ea23ca..e370c5f 100644
--- a/src/android/FileTransfer.java
+++ b/src/android/FileTransfer.java
@@ -797,9 +797,21 @@ public class FileTransfer extends CordovaPlugin {
                     Log.d(LOG_TAG, "Saved file: " + target);
     
                     // create FileEntry object
-                    JSONObject fileEntry = FileUtils.getEntry(file);
+                    FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File");
+                    if (filePlugin != null) {
+                        JSONObject fileEntry = filePlugin.getEntryForFile(file);
+                        if (fileEntry != null) {
+                            result = new PluginResult(PluginResult.Status.OK, fileEntry);
+                        } else {
+                            JSONObject error = createFileTransferError(CONNECTION_ERR, source,
target, connection);
+                            Log.e(LOG_TAG, "File plugin cannot represent download path");
+                            result = new PluginResult(PluginResult.Status.IO_EXCEPTION, error);
+                        }
+                    } else {
+                        Log.e(LOG_TAG, "File plugin not found; cannot save downloaded file");
+                        result = new PluginResult(PluginResult.Status.ERROR, "File plugin
not found; cannot save downloaded file");
+                    }
                     
-                    result = new PluginResult(PluginResult.Status.OK, fileEntry);
                 } catch (FileNotFoundException e) {
                     JSONObject error = createFileTransferError(FILE_NOT_FOUND_ERR, source,
target, connection);
                     Log.e(LOG_TAG, error.toString(), e);


Mime
View raw message