Skip to content

Commit

Permalink
Use srcStat param in copyFileFallback
Browse files Browse the repository at this point in the history
  • Loading branch information
manidlou committed Nov 11, 2017
1 parent 546216c commit d6f6da1
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/copy-sync/copy-sync.js
Expand Up @@ -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

Expand All @@ -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) {
Expand Down

0 comments on commit d6f6da1

Please sign in to comment.