|
|
@ -100,7 +100,7 @@ function copyFile (srcStat, src, dest, opts, cb) { |
|
|
|
if (typeof fs.copyFile === 'function') { |
|
|
|
return fs.copyFile(src, dest, err => { |
|
|
|
if (err) return cb(err) |
|
|
|
return handleDestModeAndTimestamps(srcStat, dest, opts, cb) |
|
|
|
return setDestModeAndTimestamps(srcStat, dest, opts, cb) |
|
|
|
}) |
|
|
|
} |
|
|
|
return copyFileFallback(srcStat, src, dest, opts, cb) |
|
|
@ -114,10 +114,10 @@ function copyFileFallback (srcStat, src, dest, opts, cb) { |
|
|
|
ws.on('error', err => cb(err)) |
|
|
|
|
|
|
|
ws.on('open', () => rs.pipe(ws)) |
|
|
|
.once('close', () => handleDestModeAndTimestamps(srcStat, dest, opts, cb)) |
|
|
|
.once('close', () => setDestModeAndTimestamps(srcStat, dest, opts, cb)) |
|
|
|
} |
|
|
|
|
|
|
|
function handleDestModeAndTimestamps (srcStat, dest, opts, cb) { |
|
|
|
function setDestModeAndTimestamps (srcStat, dest, opts, cb) { |
|
|
|
fs.chmod(dest, srcStat.mode, err => { |
|
|
|
if (err) return cb(err) |
|
|
|
if (opts.preserveTimestamps) { |
|
|
|