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

Add cloning support #40

Closed
wants to merge 10 commits into from
Closed

Conversation

Artoria2e5
Copy link

@Artoria2e5 Artoria2e5 commented Jun 16, 2020

This commit makes COPYFILE_FICLONE the default. A lot of tests may need to be changed...

Fixes #27

This commit makes COPYFILE_FICLONE the default. A lot of tests may need to
be changed...
test('clone a big file', async t => {
const buffer = crypto.randomBytes(THREE_HUNDRED_KILO);
fs.writeFileSync(t.context.source, buffer);
await cpFile(t.context.source, t.context.destination, {clone: true});
Copy link
Author

Choose a reason for hiding this comment

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

Can't make this force yet -- I can't figure out how to use different install scripts for different OS. Since cmd is super incompatible with sh I don't think I can get away with some if statements. Otherwise I would be able to make a known-fs disk image and stuff.

Copy link
Author

Choose a reason for hiding this comment

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

Oh, travis on Windows uses mingw sh. Guess I am free to do whatever.

@Artoria2e5
Copy link
Author

Artoria2e5 commented Jun 16, 2020

Eugh, xo is supposed to come up with its own ts project... This makes no sense.

Artoria2e5 and others added 4 commits June 17, 2020 15:51
I am dumb enough to require this. A few kludges still need some ignore;
the others indicate my laziness.

/**
Perform a fast copy-on-write clone (reflink) if possible.

Copy link
Owner

Choose a reason for hiding this comment

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

Not clear from the docs here what force does.

Maybe also mention some use-cases for needing to set it to false or 'force' as I cannot think of anything reason to not have this be just true all the time.

Copy link
Author

@Artoria2e5 Artoria2e5 Jul 6, 2020

Choose a reason for hiding this comment

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

This is analogous to gnu cp's --reflink=auto vs --reflink. From a usability standpoint, it is usually preferable to have a fallback (hence true), but when someone comes onto a new platform it's nice to have a test for whether reflink is supported (hence "force").

.travis.yml Show resolved Hide resolved
@@ -54,6 +55,9 @@
"sinon": "^9.0.0",
"tsd": "^0.11.0",
"uuid": "^7.0.2",
"xo": "^0.27.2"
"xo": "^0.27.2",
Copy link
Owner

Choose a reason for hiding this comment

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

Try upgrading it to the latest version. That version has built-in TS support.

Copy link
Author

Choose a reason for hiding this comment

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

The current version already does have the commit for TS support. And to quote a common saying, "it works on my machine"...

Could be travis CI caching an old version in the node_modules for some other dep though.

Copy link
Owner

Choose a reason for hiding this comment

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

Sure, but the latest XO version upgrades the TS parsers and such.

index.js Outdated Show resolved Hide resolved
progress-emitter.js Outdated Show resolved Hide resolved
* @param {string} destination
* @param {import('.').Options} options
* @param {ProgressEmitter} progressEmitter
*/
Copy link
Owner

Choose a reason for hiding this comment

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

I think all the JSDoc comments should have been added in a separate PR. Try to keep that in mind in the future. It makes it much easier to review without all the unrelated noise.

fs.js Outdated Show resolved Hide resolved
@sindresorhus
Copy link
Owner

Thanks for working on this 🙌🏻

'use strict';
const EventEmitter = require('events');
const { EventEmitter } = require('events');
Copy link
Owner

Choose a reason for hiding this comment

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

Don't do unrelated changes.

@param {string} destinationPath
@param {import('.').Options} options
@returns {Promise<void> & import('.').ProgressEmitter}
*/
Copy link
Owner

Choose a reason for hiding this comment

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

Suggested change
*/
*/

Applies everywhere.

@sindresorhus
Copy link
Owner

@Artoria2e5 Bump

Base automatically changed from master to main January 23, 2021 08:54
@sindresorhus
Copy link
Owner

@Artoria2e5 Bump

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use the COPYFILE_FICLONE constant
2 participants