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 2 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
2 changes: 1 addition & 1 deletion src/util/fs-normalized.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export const unlink: (path: string) => Promise<void> = promisify(require('rimraf
export const copyFile = async function(data: CopyFileAction, cleanup: () => mixed): Promise<void> {
try {
await unlink(data.dest);
await copyFilePoly(data.src, data.dest, 0, data);
await copyFilePoly(data.src, data.dest, (fs.constants: any).COPYFILE_FICLONE || 0, data);
Copy link
Member

@Gudahtt Gudahtt Aug 27, 2018

Choose a reason for hiding this comment

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

Hmm. This is unfortunate.

The flow error you're suppressing here is because Flow's built-in types for Node.js are missing this constant. I have submitted a PR to Flow to fix this, but even if that gets merged and released we can't immediately pull it in here. There were Flow errors introduced with a recent update that still need to be fixed first.

So in the meantime, bypassing this type check in some manner is appropriate I think. Typically this is done with a $FlowFixMe comment though, so that we know that we should come back and fix this at some point. I don't know what the maintainers would prefer here.

The benefit of using $FlowFixMe is that it would mark the line as something to fix later. You could also mention the PR that is required. The downside would be that it would suppress type errors elsewhere in this line.

It's probably worthwhile using the comment instead.

} finally {
if (cleanup) {
cleanup();
Expand Down