fs.rename() should normalize paths before using, dir vs. dir/
This commit is contained in:
parent
e9c4cb6d7a
commit
17fb8993c3
|
@ -1976,6 +1976,9 @@ function rename(fs, context, oldpath, newpath, callback) {
|
||||||
if(!pathCheck(oldpath, callback)) return;
|
if(!pathCheck(oldpath, callback)) return;
|
||||||
if(!pathCheck(newpath, callback)) return;
|
if(!pathCheck(newpath, callback)) return;
|
||||||
|
|
||||||
|
oldpath = normalize(oldpath);
|
||||||
|
newpath = normalize(newpath);
|
||||||
|
|
||||||
var oldParentPath = Path.dirname(oldpath);
|
var oldParentPath = Path.dirname(oldpath);
|
||||||
var newParentPath = Path.dirname(oldpath);
|
var newParentPath = Path.dirname(oldpath);
|
||||||
var oldName = Path.basename(oldpath);
|
var oldName = Path.basename(oldpath);
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
var Filer = require('../..');
|
||||||
|
var util = require('../lib/test-utils.js');
|
||||||
|
var expect = require('chai').expect;
|
||||||
|
|
||||||
|
describe('trailing slashes in path names to work when renaming a dir', function() {
|
||||||
|
beforeEach(util.setup);
|
||||||
|
afterEach(util.cleanup);
|
||||||
|
|
||||||
|
it('should deal with trailing slashes in rename, dir == dir/', function(done) {
|
||||||
|
var fs = util.fs();
|
||||||
|
|
||||||
|
fs.mkdir('/tmp', function(err) {
|
||||||
|
if(err) throw err;
|
||||||
|
|
||||||
|
fs.rename('/tmp/', '/new-tmp/', function(err) {
|
||||||
|
if(err) throw err;
|
||||||
|
|
||||||
|
fs.stat('/new-tmp', function(err, stats) {
|
||||||
|
if(err) throw err;
|
||||||
|
expect(stats).to.exist;
|
||||||
|
expect(stats.isDirectory()).to.be.true;
|
||||||
|
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
|
@ -75,3 +75,4 @@ require("./bugs/issue254.js");
|
||||||
require("./bugs/issue258.js");
|
require("./bugs/issue258.js");
|
||||||
require("./bugs/issue267.js");
|
require("./bugs/issue267.js");
|
||||||
require("./bugs/issue270.js");
|
require("./bugs/issue270.js");
|
||||||
|
require("./bugs/rename-dir-trailing-slash.js");
|
||||||
|
|
Loading…
Reference in New Issue