diff --git a/lib/copy-sync/copy-sync.js b/lib/copy-sync/copy-sync.js index 81adc397..35387224 100644 --- a/lib/copy-sync/copy-sync.js +++ b/lib/copy-sync/copy-sync.js @@ -90,8 +90,7 @@ function copyFileFallback (srcStat, src, dest, opts) { const _buff = require('../util/buffer')(BUF_LENGTH) const fdr = fs.openSync(src, 'r') - const stat = fs.fstatSync(fdr) - const fdw = fs.openSync(dest, 'w', stat.mode) + const fdw = fs.openSync(dest, 'w', srcStat.mode) let bytesRead = 1 let pos = 0 @@ -101,11 +100,9 @@ function copyFileFallback (srcStat, src, dest, opts) { pos += bytesRead } - fs.fchmodSync(fdw, srcStat.mode) - if (opts.preserveTimestamps) fs.futimesSync(fdw, srcStat.atime, srcStat.mtime) - fs.closeSync(fdr) fs.closeSync(fdw) + if (opts.preserveTimestamps) return utimesSync(dest, srcStat.atime, srcStat.mtime) } function onDir (srcStat, src, dest, opts) {