don't update mtime when renaming directory

This commit is contained in:
Myk Melez 2014-12-29 11:25:23 -08:00
Родитель 155484dd7e
Коммит a6c14f99d4
4 изменённых файлов: 28 добавлений и 22 удалений

Просмотреть файл

@ -832,36 +832,26 @@ var fs = (function() {
return; return;
} }
var recreatePath = remove.bind(null, oldPath, function(removed) { var moveItem = function() {
if (!removed) { store.removeItem(oldPath);
cb(false); oldRecord.parentDir = dirname(newPath);
return; store.setItem(newPath, oldRecord);
} cb(true);
};
if (oldRecord.isDir) {
mkdir(newPath, cb);
} else {
create(newPath, oldRecord.data, cb);
}
});
if (oldRecord.isDir) { if (oldRecord.isDir) {
store.isEmpty(oldPath, function(empty) { store.isEmpty(oldPath, function(empty) {
if (empty) { if (empty) {
recreatePath(); moveItem();
} else { } else {
// If the old path is a dir with files in it, we don't move it. // If the old path is a dir with files in it, we don't move it.
// We should move it along with its files // We should move it along with its files
console.error("rename directory containing files not implemented: " + oldPath + " to " + newPath); console.error("rename directory containing files not implemented: " + oldPath + " to " + newPath);
cb(false); cb(false);
return;
} }
}); });
} else { } else {
store.removeItem(oldPath); moveItem();
oldRecord.parentDir = dirname(newPath);
store.setItem(newPath, oldRecord);
cb(true);
} }
}); });
} }

Просмотреть файл

@ -159,7 +159,7 @@ casper.test.begin("unit tests", 11 + gfxTests.length, function(test) {
casper casper
.thenOpen("http://localhost:8000/tests/fs/fstests.html") .thenOpen("http://localhost:8000/tests/fs/fstests.html")
.waitForText("DONE", function() { .waitForText("DONE", function() {
test.assertTextExists("DONE: 137 PASS, 0 FAIL", "run fs.js unit tests"); test.assertTextExists("DONE: 138 PASS, 0 FAIL", "run fs.js unit tests");
syncFS(); syncFS();
}); });

Просмотреть файл

@ -43,7 +43,7 @@ casper.test.begin("fs tests", 6, function(test) {
casper casper
.thenOpen("http://localhost:8000/tests/fs/fstests.html") .thenOpen("http://localhost:8000/tests/fs/fstests.html")
.waitForText("DONE", function() { .waitForText("DONE", function() {
test.assertTextExists("DONE: 137 PASS, 0 FAIL", "run fs.js unit tests"); test.assertTextExists("DONE: 138 PASS, 0 FAIL", "run fs.js unit tests");
}); });
casper casper
@ -66,7 +66,7 @@ casper.test.begin("fs tests", 6, function(test) {
casper casper
.thenOpen("http://localhost:8000/tests/fs/fstests.html") .thenOpen("http://localhost:8000/tests/fs/fstests.html")
.waitForText("DONE", function() { .waitForText("DONE", function() {
test.assertTextExists("DONE: 137 PASS, 0 FAIL", "run fs.js unit tests"); test.assertTextExists("DONE: 138 PASS, 0 FAIL", "run fs.js unit tests");
}); });
casper casper
@ -89,7 +89,7 @@ casper.test.begin("fs tests", 6, function(test) {
casper casper
.thenOpen("http://localhost:8000/tests/fs/fstests.html") .thenOpen("http://localhost:8000/tests/fs/fstests.html")
.waitForText("DONE", function() { .waitForText("DONE", function() {
test.assertTextExists("DONE: 137 PASS, 0 FAIL", "run fs.js unit tests"); test.assertTextExists("DONE: 138 PASS, 0 FAIL", "run fs.js unit tests");
}); });
casper casper

Просмотреть файл

@ -940,6 +940,22 @@ tests.push(function() {
}); });
})(); })();
tests.push(function() {
fs.mkdir("/tmp/stat", function() {
fs.stat("/tmp/stat", function(stat) {
var mtime = stat.mtime;
window.setTimeout(function() {
fs.rename("/tmp/stat", "/tmp/stat2", function() {
fs.stat("/tmp/stat2", function(stat) {
is(stat.mtime, mtime, "rename directory doesn't update mtime");
next();
});
});
}, 1);
});
});
});
tests.push(function() { tests.push(function() {
fs.mkdir("/statDir", function() { fs.mkdir("/statDir", function() {
fs.stat("/statDir", function(stat) { fs.stat("/statDir", function(stat) {