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/07/08 20:45:07 UTC

[2/4] git commit: CB-6928: Open output stream only if it's necessary.

CB-6928: Open output stream only if it's necessary.


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

Branch: refs/heads/master
Commit: 22f1ea573c4eadf784b7731fc4a4d815fa0a067b
Parents: 4e5f10c
Author: Javier Puerto <ja...@becompany.ch>
Authored: Thu Jun 12 10:34:42 2014 +0200
Committer: Ian Clelland <ic...@chromium.org>
Committed: Tue Jul 8 14:14:12 2014 -0400

----------------------------------------------------------------------
 src/android/FileTransfer.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/22f1ea57/src/android/FileTransfer.java
----------------------------------------------------------------------
diff --git a/src/android/FileTransfer.java b/src/android/FileTransfer.java
index c04c0d3..2b1a2f0 100644
--- a/src/android/FileTransfer.java
+++ b/src/android/FileTransfer.java
@@ -716,7 +716,6 @@ public class FileTransfer extends CordovaPlugin {
                 OutputStream outputStream = null;
                 try {
                     OpenForReadResult readResult = null;
-                    outputStream = resourceApi.openOutputStream(targetUri);
 
                     file = resourceApi.mapUriToFile(targetUri);
                     context.targetFile = file;
@@ -787,6 +786,7 @@ public class FileTransfer extends CordovaPlugin {
                         // write bytes to file
                         byte[] buffer = new byte[MAX_BUFFER_SIZE];
                         int bytesRead = 0;
+                        outputStream = resourceApi.openOutputStream(targetUri);
                         while ((bytesRead = inputStream.read(buffer)) > 0) {
                             outputStream.write(buffer, 0, bytesRead);
                             // Send a progress event.
@@ -854,7 +854,6 @@ public class FileTransfer extends CordovaPlugin {
                     Log.e(LOG_TAG, error.toString(), e);
                     result = new PluginResult(PluginResult.Status.IO_EXCEPTION, error);
                 } finally {
-                    safeClose(outputStream);
                     synchronized (activeRequests) {
                         activeRequests.remove(objectId);
                     }