cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From an-s...@apache.org
Subject cordova-plugin-file git commit: CB-12112 windows: Make available to move folder trees
Date Thu, 24 Nov 2016 14:53:46 GMT
Repository: cordova-plugin-file
Updated Branches:
  refs/heads/master f4c2c94c2 -> a1cfabdce


CB-12112 windows: Make available to move folder trees

There was a mistake in the logic of recursive function for moving operation. As for destination
folder, it was always used start folder.

 This closes #198


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

Branch: refs/heads/master
Commit: a1cfabdce07cabd44694097fac6730b7317d4607
Parents: f4c2c94
Author: Nikita Matrosov <matrosov.nikita94@gmail.com>
Authored: Fri Nov 18 11:50:20 2016 +0300
Committer: Vladimir Kotikov <v-vlkoti@microsoft.com>
Committed: Thu Nov 24 17:53:16 2016 +0300

----------------------------------------------------------------------
 src/windows/FileProxy.js |  4 ++--
 tests/tests.js           | 31 +++++++++++++++++++++++++++++++
 2 files changed, 33 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/a1cfabdc/src/windows/FileProxy.js
----------------------------------------------------------------------
diff --git a/src/windows/FileProxy.js b/src/windows/FileProxy.js
index 64ee1df..fa56a53 100644
--- a/src/windows/FileProxy.js
+++ b/src/windows/FileProxy.js
@@ -404,8 +404,8 @@ function moveFolder(src,dst,name) {
                         src.deleteAsync().done(complete,failed);
                         return;
                     }
-                    moveFolder(the.folders[todo],dst)
-                    .done(movefolders,failed); 
+                    moveFolder(the.folders[todo], the.fld)
+                    .done(movefolders,failed);
                 };
                 var movefiles = function() {
                     if (!(todo--)) {

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/a1cfabdc/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index eb74c14..acdcfa0 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -1758,6 +1758,37 @@ exports.defineAutoTests = function () {
                     }, failed.bind(null, done, 'createDirectory - Error creating directory
: ' + srcDir));
                 }, failed.bind(null, done, 'deleteEntry - Error removing directory : ' +
dstDir));
             });
+
+            it("file.spec.131 moveTo: directories tree to new parent", function (done) {
+                if (isIndexedDBShim) {
+                    /* `copyTo` and `moveTo` functions do not support directories (Firefox,
IE) */
+                    pending();
+                }
+
+                var srcDir = "entry.move.dnp.srcDir";
+                var srcDirNestedFirst = "entry.move.dnp.srcDir.Nested1";
+                var srcDirNestedSecond = "entry.move.dnp.srcDir.Nested2";
+                var dstDir = "entry.move.dnp.dstDir";
+
+                createDirectory(dstDir, function (dstDirectory) {
+                    createDirectory(srcDir, function (srcDirectory) {
+                        srcDirectory.getDirectory(srcDirNestedFirst, { create: true }, function
() {
+                            srcDirectory.getDirectory(srcDirNestedSecond, { create: true
}, function () {
+                                srcDirectory.moveTo(dstDirectory, srcDir, function successMove(transferredDirectory)
{
+                                    var directoryReader = transferredDirectory.createReader();
+                                    directoryReader.readEntries(function successRead(entries)
{
+                                        expect(entries.length).toBe(2);
+                                        expect(entries[0].name).toBe(srcDirNestedFirst);
+                                        expect(entries[1].name).toBe(srcDirNestedSecond);
+                                        deleteEntry(dstDir, done);
+                                    }, failed.bind(null, done, 'Error getting entries from:
' + transferredDirectory));
+                                }, failed.bind(null, done, 'directory.moveTo - Error moving
directory : ' + srcDir + ' to root as: ' + dstDir));
+                            }, failed.bind(null, done, 'directory.getDirectory - Error creating
directory : ' + srcDirNestedSecond));
+                        }, failed.bind(null, done, 'directory.getDirectory - Error creating
directory : ' + srcDirNestedFirst));
+                    }, failed.bind(null, done, 'createDirectory - Error creating source directory
: ' + srcDir));
+                }, failed.bind(null, done, 'createDirectory - Error creating dest directory
: ' + dstDir));
+            });
+
             it("file.spec.70 moveTo: directory onto itself", function (done) {
                 if (isIndexedDBShim) {
                     /* `copyTo` and `moveTo` functions do not support directories (Firefox,
IE) */


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message