Closed
Description
- Operating System: Xubuntu 16.04 LTS
- Node.js version: v8.12.0
fs-extra
version: 7.0.0
Copying a directory using the recursive copySync
function with preserveTimestamps
option fails with permission error on Linux if the target is a directory contains read-only file.
(This issue is similar to #599, but the problem still remains ever now)
Repro steps:
- Create the following hierarchy:
root
|- file1 (r--r--r--)
|- file2 (rw-rw-r--)
- Run the following node snippet:
const fse = require('fs-extra')
fse.copySync('root', 'target', {preserveTimestamps: true})
- Expected: success (like
cp -pr root target
) - Actual: the
target
directory is created andfile1
file, but notfile2
and the following is printed:
fs.js:646
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: EACCES: permission denied, open 'target/file1'
at Object.fs.openSync (fs.js:646:18)
at utimesMillisSync (***/node_modules/fs-extra/lib/util/utimes.js:68:17)
at copyFile (***/node_modules/fs-extra/lib/copy-sync/copy-sync.js:69:14)
at onFile (***/node_modules/fs-extra/lib/copy-sync/copy-sync.js:51:37)
at getStats (***/node_modules/fs-extra/lib/copy-sync/copy-sync.js:46:44)
at startCopy (***/node_modules/fs-extra/lib/copy-sync/copy-sync.js:36:10)
at copyDirItem (***/node_modules/fs-extra/lib/copy-sync/copy-sync.js:118:10)
at fs.readdirSync.forEach.item (***/node_modules/fs-extra/lib/copy-sync/copy-sync.js:111:39)
at Array.forEach (<anonymous>)
at copyDir (***/node_modules/fs-extra/lib/copy-sync/copy-sync.js:111:23)