Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use UV_FS_COPYFILE_FICLONE flag in fs.copyFile when available #6302

Merged
merged 3 commits into from
Sep 5, 2018
Merged
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
4 changes: 3 additions & 1 deletion src/util/fs-normalized.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@ export const unlink: (path: string) => Promise<void> = promisify(require('rimraf
* to force the correct naming when the filename has changed only in character-casing. (Jest -> jest).
*/
export const copyFile = async function(data: CopyFileAction, cleanup: () => mixed): Promise<void> {
// $FlowFixMe: Flow doesn't currently support COPYFILE_FICLONE
const ficloneFlag = fs.constants.COPYFILE_FICLONE || 0;
try {
await unlink(data.dest);
await copyFilePoly(data.src, data.dest, 0, data);
await copyFilePoly(data.src, data.dest, ficloneFlag, data);
} finally {
if (cleanup) {
cleanup();
Expand Down