Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/internal/fs/cp/cp-sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ const {
symlinkSync,
unlinkSync,
utimesSync,
constants: {
COPYFILE_FICLONE,
},
} = require('fs');
const {
dirname,
Expand Down Expand Up @@ -226,7 +229,7 @@ function mayCopyFile(srcStat, src, dest, opts) {
}

function copyFile(srcStat, src, dest, opts) {
copyFileSync(src, dest);
copyFileSync(src, dest, COPYFILE_FICLONE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like something that users should pass in via cp()'s options argument, and not something that Node core sets unconditionally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I withdeaw this pr. Thank you for your review!

if (opts.preserveTimestamps) handleTimestamps(srcStat.mode, src, dest);
return setDestMode(dest, srcStat.mode);
}
Expand Down
5 changes: 4 additions & 1 deletion lib/internal/fs/cp/cp.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ const {
symlink,
unlink,
utimes,
constants: {
COPYFILE_FICLONE,
},
} = require('fs/promises');
const {
dirname,
Expand Down Expand Up @@ -257,7 +260,7 @@ async function mayCopyFile(srcStat, src, dest, opts) {
}

async function _copyFile(srcStat, src, dest, opts) {
await copyFile(src, dest);
await copyFile(src, dest, COPYFILE_FICLONE);
if (opts.preserveTimestamps) {
return handleTimestampsAndMode(srcStat.mode, src, dest);
}
Expand Down