From d6f6da1e7172cc06b974e5a6f3e202f5d1bdc6ae Mon Sep 17 00:00:00 2001 From: Mani Maghsoudlou Date: Sat, 11 Nov 2017 01:01:40 -0800 Subject: [PATCH] Use srcStat param in copyFileFallback --- lib/copy-sync/copy-sync.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) 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) {