You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by pu...@apache.org on 2014/12/05 21:22:51 UTC
[1/2] cordova-plugin-file-transfer git commit: CB-8093 Fixes
incorrect FileTransferError returned in case of download failure
Repository: cordova-plugin-file-transfer
Updated Branches:
refs/heads/master 7ee3bcaf5 -> f415f35c2
CB-8093 Fixes incorrect FileTransferError returned in case of download failure
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/80aa8280
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/80aa8280
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/80aa8280
Branch: refs/heads/master
Commit: 80aa82802183f7b9794064fd984b1b646c0ecaaa
Parents: 6fee835
Author: Vladimir Kotikov <v-...@microsoft.com>
Authored: Thu Nov 27 17:45:42 2014 +0300
Committer: Vladimir Kotikov <v-...@microsoft.com>
Committed: Thu Nov 27 18:32:34 2014 +0300
----------------------------------------------------------------------
src/windows/FileTransferProxy.js | 56 +++++++++++++++++++----------------
1 file changed, 31 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/blob/80aa8280/src/windows/FileTransferProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/FileTransferProxy.js b/src/windows/FileTransferProxy.js
index 0eeef90..273dd65 100644
--- a/src/windows/FileTransferProxy.js
+++ b/src/windows/FileTransferProxy.js
@@ -236,34 +236,40 @@ exec(win, fail, 'FileTransfer', 'upload',
successCallback && successCallback(new FileEntry(storageFile.name, storageFile.path, null, nativeURI));
}, function(error) {
- var result;
- // Handle download error here. If download was cancelled,
- // message property will be specified
- if (error.message == 'Canceled') {
- result = new FileTransferError(FileTransferError.ABORT_ERR, source, target, null, null, error);
- } else {
- // in the other way, try to get response property
- var response = download.getResponseInformation();
- if (!response) {
- result = new FileTransferError(FileTransferError.CONNECTION_ERR, source, target);
- } else if (response.statusCode == 401 || response.statusCode == 404) {
- result = new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR, source, target, response.statusCode, null, error);
+ var getTransferError = new WinJS.Promise(function (resolve) {
+ // Handle download error here. If download was cancelled,
+ // message property will be specified
+ if (error.message === 'Canceled') {
+ resolve(new FileTransferError(FileTransferError.ABORT_ERR, source, target, null, null, error));
+ } else {
+ // in the other way, try to get response property
+ var response = download.getResponseInformation();
+ if (!response) {
+ resolve(new FileTransferError(FileTransferError.CONNECTION_ERR, source, target));
+ } else {
+ var reader = new Windows.Storage.Streams.DataReader(download.getResultStreamAt(0));
+ reader.loadAsync(download.progress.bytesReceived).then(function (bytesLoaded) {
+ var payload = reader.readString(bytesLoaded);
+ resolve(new FileTransferError(FileTransferError.FILE_NOT_FOUND_ERR, source, target, response.statusCode, payload, error));
+ });
+ }
}
- }
-
- // Update TransferOperation object with new state, delete promise property
- // since it is not actual anymore
- var currentDownloadOp = fileTransferOps[downloadId];
- if (currentDownloadOp) {
- currentDownloadOp.state = FileTransferOperation.CANCELLED;
- currentDownloadOp.promise = null;
- }
-
- // Cleanup, remove incompleted file
- storageFile.deleteAsync().then(function () {
- errorCallback && errorCallback(result);
});
+ getTransferError.then(function (fileTransferError) {
+
+ // Update TransferOperation object with new state, delete promise property
+ // since it is not actual anymore
+ var currentDownloadOp = fileTransferOps[downloadId];
+ if (currentDownloadOp) {
+ currentDownloadOp.state = FileTransferOperation.CANCELLED;
+ currentDownloadOp.promise = null;
+ }
+ // Cleanup, remove incompleted file
+ storageFile.deleteAsync().then(function() {
+ errorCallback && errorCallback(fileTransferError);
+ });
+ });
}, function(evt) {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org
[2/2] cordova-plugin-file-transfer git commit: Merge branch 'CB-8093'
of https://github.com/MSOpenTech/cordova-plugin-file-transfer
Posted by pu...@apache.org.
Merge branch 'CB-8093' of https://github.com/MSOpenTech/cordova-plugin-file-transfer
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/f415f35c
Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/tree/f415f35c
Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file-transfer/diff/f415f35c
Branch: refs/heads/master
Commit: f415f35c20660065dd6223b92290b18c82784156
Parents: 7ee3bca 80aa828
Author: Jesse MacFadyen <pu...@gmail.com>
Authored: Fri Dec 5 12:22:21 2014 -0800
Committer: Jesse MacFadyen <pu...@gmail.com>
Committed: Fri Dec 5 12:22:21 2014 -0800
----------------------------------------------------------------------
src/windows/FileTransferProxy.js | 56 +++++++++++++++++++----------------
1 file changed, 31 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org