You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
, when overwriting, the target is first removed. This is not an atomic operation and can leave the target removed but the source in place.
However, the rename call already removes the target, and this is an atomic operation.
So IMHO, move should only check if the target exists when not overwriting, it should not delete the file itself. (and if the source and target have the same inode, it should not count as already existing, #801)
The text was updated successfully, but these errors were encountered:
Set out to fix this today; I didn't read the docs close enough:
In the case that newPath already exists, it will be overwritten. If there is a directory at newPath, an error will be raised instead.
We support moving dirs, and at this stage in the code, we know nothing about the state of the destination. We're gonna have to be non-atomic for dirs anyhow; so I'm going to elect to leave this as-is. If you're working with files only, and you need perfect atomic behavior, use fs.rename directly.
fs-extra
version: latestAs you can see in
node-fs-extra/lib/move/move.js
Lines 34 to 37 in 6bffcd8
However, the rename call already removes the target, and this is an atomic operation.
So IMHO,
move
should only check if the target exists when not overwriting, it should not delete the file itself. (and if the source and target have the same inode, it should not count as already existing, #801)The text was updated successfully, but these errors were encountered: