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/11/11 18:44:46 UTC

cordova-plugin-file git commit: CB-7602: Fix isCopyOnItself logic

Repository: cordova-plugin-file
Updated Branches:
  refs/heads/master 8ef744d28 -> 0b5096eab


CB-7602: Fix isCopyOnItself logic

It should not treat /a/bc/ as a subdirectory of /a/b/


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

Branch: refs/heads/master
Commit: 0b5096eab58fd3333d5aa4d55460e8423e2aa27a
Parents: 8ef744d
Author: Ian Clelland <ic...@chromium.org>
Authored: Tue Nov 11 11:24:08 2014 -0500
Committer: Ian Clelland <ic...@chromium.org>
Committed: Tue Nov 11 12:43:22 2014 -0500

----------------------------------------------------------------------
 src/android/LocalFilesystem.java |  6 +-----
 tests/tests.js                   | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/0b5096ea/src/android/LocalFilesystem.java
----------------------------------------------------------------------
diff --git a/src/android/LocalFilesystem.java b/src/android/LocalFilesystem.java
index 05cda35..9bbd7f8 100644
--- a/src/android/LocalFilesystem.java
+++ b/src/android/LocalFilesystem.java
@@ -305,11 +305,7 @@ public class LocalFilesystem extends Filesystem {
         // This weird test is to determine if we are copying or moving a directory into itself.
         // Copy /sdcard/myDir to /sdcard/myDir-backup is okay but
         // Copy /sdcard/myDir to /sdcard/myDir/backup should throw an INVALID_MODIFICATION_ERR
-        if (dest.startsWith(src) && dest.indexOf(File.separator, src.length() - 1) != -1) {
-            return true;
-        }
-
-        return false;
+        return dest.equals(src) || dest.startsWith(src + File.separator);
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/cordova-plugin-file/blob/0b5096ea/tests/tests.js
----------------------------------------------------------------------
diff --git a/tests/tests.js b/tests/tests.js
index 6d625b9..0bce0f5 100644
--- a/tests/tests.js
+++ b/tests/tests.js
@@ -1599,6 +1599,24 @@ exports.defineAutoTests = function () {
                     });
                 }, failed.bind(null, done, 'createDirectory - Error creating directory : ' + srcDir));
             });
+            it("file.spec.130 moveTo: directory into similar directory", function (done) {
+                var srcDir = "entry.move.dis.srcDir",
+                dstDir = "entry.move.dis.srcDir-backup",
+                srcPath = joinURL(root.fullPath, srcDir);
+                // create a new directory entry to kick off it
+                createDirectory(srcDir, function (srcDirEntry) {
+                deleteEntry(dstDir, function () {
+                createDirectory(dstDir, function (dstDirEntry) {
+                    // move source directory into itself
+                    srcDirEntry.moveTo(dstDirEntry, 'file', function (newDirEntry) {
+                        expect(newDirEntry).toBeDefined();
+                        deleteEntry(dstDir);
+                        done();
+                    }, failed.bind(null, done, 'directory.moveTo - Error moving a directory into a similarly-named directory: ' + srcDir));
+                }, failed.bind(null, done, 'createDirectory - Error creating directory : ' + dstDir));
+                }, failed.bind(null, done, 'deleteEntry - Error deleting directory : ' + dstDir));
+                }, failed.bind(null, done, 'createDirectory - Error creating directory : ' + srcDir));
+            });
             it("file.spec.72 moveTo: file onto itself", function (done) {
                 var file1 = "entry.move.fos.file1",
                 filePath = joinURL(root.fullPath, file1);


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