node-fs-extra: fs.move fails with chmod error when disk under heavy use
Using fs-extra v2.0.0 I noticed that fs.move
, which uses /lib/copy/ncp
under the hood, fails with a chmod
error when the disk is under heavy use.
{ Error: ENOENT: no such file or directory, chmod '/the/path-a/file'
errno: -2,
code: 'ENOENT',
syscall: 'chmod',
path: '/the/path-b/file' }
In this case I’m moving a very large directory of a few files.
I’m using pify on fs.move
:
const binary = (func) => (a, b) => func(a, b)
const move = binary(pify(fs.move))
// ...
move('/the/path-a', '/the/path-b')
With this error on the move operation what ends up happening is that path-a
will still exist with one or so of its files left but path-b
is created and contains all files (at least it contains a copy of the file remaining in path-a
).
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 25 (17 by maintainers)
@jdalton fs-extra uses
fs.rename
when possible, if that’s not possible it usesncp
and deletes the source.@manidlou We don’t use node-mv as a dependency;
lib/move/index.js
is a fork of node-mv.@jdalton We don’t want to shell out to
mv
for a few reasons:child_process
is kinda slow