This seems related to #23. If oldFilepath and newFilepath are equal, then the file is deleted; I'm not sure if this is the default node fs behavior, but we can see this is because the old file is deleted after the new file is inserted here:
rename(oldFilepath, newFilepath) {
let basename = path.basename(newFilepath);
// Note: do both lookups before making any changes
// so if lookup throws, we don't lose data (issue #23)
// grab references
let entry = this._lookup(oldFilepath);
let destDir = this._lookup(path.dirname(newFilepath));
// insert into new parent directory
destDir.set(basename, entry);
// remove from old parent directory
this.unlink(oldFilepath)
}
A simple fix would be to check for that condition, and return without doing anything:
rename(oldFilepath, newFilepath) {
if (oldFilepath == newFilepath)
return;
...
}
This seems related to #23. If
oldFilepath
andnewFilepath
are equal, then the file is deleted; I'm not sure if this is the default node fs behavior, but we can see this is because the old file is deleted after the new file is inserted here:A simple fix would be to check for that condition, and return without doing anything: