Return-Path: X-Original-To: apmail-cordova-commits-archive@www.apache.org Delivered-To: apmail-cordova-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C21D117672 for ; Fri, 10 Oct 2014 08:47:52 +0000 (UTC) Received: (qmail 94074 invoked by uid 500); 10 Oct 2014 08:47:52 -0000 Delivered-To: apmail-cordova-commits-archive@cordova.apache.org Received: (qmail 94044 invoked by uid 500); 10 Oct 2014 08:47:52 -0000 Mailing-List: contact commits-help@cordova.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Delivered-To: mailing list commits@cordova.apache.org Received: (qmail 94035 invoked by uid 99); 10 Oct 2014 08:47:52 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Oct 2014 08:47:52 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 5298219976; Fri, 10 Oct 2014 08:47:52 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: an-selm@apache.org To: commits@cordova.apache.org Date: Fri, 10 Oct 2014 08:47:52 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] git commit: CB-6994 Fixes result, returned by proxy's write method Repository: cordova-plugin-file Updated Branches: refs/heads/master 813356851 -> ab9ff4d8d CB-6994 Fixes result, returned by proxy's write method + Refactors writeBlobAsync function + Fixes proxy's remove method failure when trying to delete non-existent file Project: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/commit/cfcb74ca Tree: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/tree/cfcb74ca Diff: http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/diff/cfcb74ca Branch: refs/heads/master Commit: cfcb74ca972134eb361fc89c7b419ad912b70972 Parents: 8133568 Author: Vladimir Kotikov Authored: Fri Oct 10 12:39:16 2014 +0400 Committer: Vladimir Kotikov Committed: Fri Oct 10 12:45:42 2014 +0400 ---------------------------------------------------------------------- src/windows/FileProxy.js | 54 +++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 35 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/cfcb74ca/src/windows/FileProxy.js ---------------------------------------------------------------------- diff --git a/src/windows/FileProxy.js b/src/windows/FileProxy.js index 5d1f7ca..9910c54 100644 --- a/src/windows/FileProxy.js +++ b/src/windows/FileProxy.js @@ -64,35 +64,21 @@ var getFileFromPathAsync = Windows.Storage.StorageFile.getFileFromPathAsync; var writeBytesAsync = Windows.Storage.FileIO.writeBytesAsync; var writeTextAsync = Windows.Storage.FileIO.writeTextAsync; var writeBlobAsync = function writeBlobAsync(storageFile, data) { - return new WinJS.Promise(function (resolve, reject) { - storageFile.openAsync(Windows.Storage.FileAccessMode.readWrite).then( - function (output) { - var input = (data.detachStream || data.msDetachStream).call(data); - - // Copy the stream from the blob to the File stream - Windows.Storage.Streams.RandomAccessStream.copyAsync(input, output).then( - function () { - output.flushAsync().done( - function () { - input.close(); - output.close(); - - resolve(data.length); - }, - function () { - reject(FileError.INVALID_MODIFICATION_ERR); - } - ); - }, - function () { - reject(FileError.INVALID_MODIFICATION_ERR); - } - ); - }, - function () { - reject(FileError.INVALID_MODIFICATION_ERR); - } - ); + return storageFile.openAsync(Windows.Storage.FileAccessMode.readWrite) + .then(function (output) { + var dataSize = data.size; + var input = (data.detachStream || data.msDetachStream).call(data); + + // Copy the stream from the blob to the File stream + return Windows.Storage.Streams.RandomAccessStream.copyAsync(input, output) + .then(function () { + return output.flushAsync().then(function () { + input.close(); + output.close(); + + return dataSize; + }); + }); }); }; @@ -363,12 +349,9 @@ module.exports = { var fullPath = cordovaPathToNative(args[0]); getFileFromPathAsync(fullPath).then( - function (sFile) { - getFileFromPathAsync(fullPath).done(function (storageFile) { + function (storageFile) { storageFile.deleteAsync().done(win, function () { fail(FileError.INVALID_MODIFICATION_ERR); - - }); }); }, function () { @@ -587,8 +570,9 @@ module.exports = { storageFolder.createFileAsync(file, Windows.Storage.CreationCollisionOption.openIfExists).done( function (storageFile) { writePromise(storageFile, data).done( - function () { - win(data.length); + function (bytesWritten) { + var written = bytesWritten || data.length; + win(written); }, function () { fail(FileError.INVALID_MODIFICATION_ERR); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org For additional commands, e-mail: commits-help@cordova.apache.org