| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Since these are already being checked on the js side, perhaps just a CHECK in here?
Sorry, something went wrong.
There was a problem hiding this comment.
The JS layer checks don't actually verify this.
Sorry, something went wrong.
There was a problem hiding this comment.
ugh.. that's right. hmmm. we should definitely fix that.
would much prefer any new errors to go through the internal/errors path.
Sorry, something went wrong.
There was a problem hiding this comment.
I agree. fs.js in general needs some TLC.
Sorry, something went wrong.
There was a problem hiding this comment.
I'll see if I can schedule some time next week to work on that. The risk, of course, is that fs is one of the most-monkey-patched modules out there and we risk breaking a lot of people by being too aggressive.
Sorry, something went wrong.
There was a problem hiding this comment.
fs is one of the most-monkey-patched modules out there and we risk breaking a lot of people by being too aggressive.
For new methods in fs it might then make sense to be more aggressive rather than not. Personally, the more assertions the better. Keeps things sharp.
Sorry, something went wrong.
There was a problem hiding this comment.
Are we certain this should be the default? I don't want to see bug reports later about how Node.js made it so that their files were all screwed up... and there is a non-zero chance of abusing this.
Sorry, something went wrong.
There was a problem hiding this comment.
Yes. cp defaults to overwriting, as does our own fs.rename().
Sorry, something went wrong.
There was a problem hiding this comment.
Yeah, I'm aware, just makes me rather cringy. Guess I'll grit my teeth and bear it.
Sorry, something went wrong.
|
So far this is looking great. I assume the libuv commit is temporary? |
Sorry, something went wrong.
There was a problem hiding this comment.
Perhaps add a note that makes it clear that the default behavior is to overwrite?
Also, a simple example is always helpful.
Sorry, something went wrong.
Yes, I explained in more detail in the original post. |
Sorry, something went wrong.
|
ha! if that first bullet was already there and I just missed it, forgive me :-) |
Sorry, something went wrong.
There was a problem hiding this comment.
I would love to see a code example in the docs
Sorry, something went wrong.
There was a problem hiding this comment.
There will be one.
Sorry, something went wrong.
|
Oh, btw, @cjihrig ... have you tested what happens if there's a file read or write error in the middle of the copy operation? Say, for instance, if the device goes down during? |
Sorry, something went wrong.
|
any possible way to observe copy progress? |
Sorry, something went wrong.
|
@jasnell So, there are few platform specific underlying implementations in libuv. It's possible that Windows' CopyFile() might do something different from macOS' copyfile() in that case. But, in libuv, there is a sendfile() fallback that attempts to delete the destination file if anything goes wrong during the actual copy. @YurySolovyov no, not currently. |
Sorry, something went wrong.
|
@cjihrig ... ok, thanks for the clarification there. It may be something that we need to watch for across platforms so we can document any differences in behavior. In particular, I want to be clear about whether or not the operation is atomic. |
Sorry, something went wrong.
|
I would prefer to make no guarantees of atomicity, especially at the level of Node. The platform specific calls could change without our knowledge, and there is at least one non-atomic path through libuv (see warning here). I think it's fair to say we'll make a best effort to remove the destination file if something goes wrong. |
Sorry, something went wrong.
|
+1 ... can you, perhaps, add a comment to that effect in the docs? |
Sorry, something went wrong.
|
@jasnell this should be ready now. The libuv update is complete, and the temporary commit removed. I think I've added all of the examples and documentation notes that you requested. |
Sorry, something went wrong.
There was a problem hiding this comment.
Did we ever reach a conclusion whether to include require()s in examples? The fs API does both at the moment.
Sorry, something went wrong.
There was a problem hiding this comment.
I updated the code samples to include the require()s
Sorry, something went wrong.
|
The test does not appear to work on v8.x Path: parallel/test-fs-copyfile
assert.js:41
throw new errors.AssertionError({
^
AssertionError [ERR_ASSERTION]: undefined === 'ERR_INVALID_ARG_TYPE'
at Object.<anonymous> (/Users/mborins/code/node/master/test/common/index.js:703:12)
at Object.<anonymous> (/Users/mborins/code/node/master/test/common/index.js:509:15)
at expectedException (assert.js:589:19)
at innerThrows (assert.js:623:21)
at Function.throws (assert.js:637:3)
at Object.expectsError (/Users/mborins/code/node/master/test/common/index.js:737:12)
at Object.<anonymous> (/Users/mborins/code/node/master/test/parallel/test-fs-copyfile.js:63:8)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
Would you be willing to manually backport? |
Sorry, something went wrong.
Fixes: nodejs#14906 PR-URL: nodejs#15034 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Notable Changes * build: * Snapshots are now re-enabled in V8 #14875 * console: * Implement minimal `console.group()`. #14910 * deps: * upgrade libuv to 1.14.1 #14866 * update nghttp2 to v1.25.0 #14955 * dns: * Add `verbatim` option to dns.lookup(). When true, results from the DNS resolver are passed on as-is, without the reshuffling that Node.js otherwise does that puts IPv4 addresses before IPv6 addresses. #14731 * fs: * add fs.copyFile and fs.copyFileSync which allows for more efficient copying of files. #15034 * inspector: * Enable async stack traces #13870 * module: * Add support for ESM. This is currently behind the `--experimental-modules` flag and requires the .mjs extension. `node --experimental-modules index.mjs` #14369 * napi: * implement promise #14365 * os: * Add support for CIDR notation to the output of the networkInterfaces() method. #14307 * perf_hooks: * An initial implementation of the Performance Timing API for Node.js. This is the same Performance Timing API implemented by modern browsers with a number of Node.js specific properties. The User Timing mark() and measure() APIs are implemented, as is a Node.js specific flavor of the Frame Timing for measuring event loop duration. #14680 * tls: * multiple PFX in createSecureContext [#14793](#14793) * Added new collaborators: * BridgeAR – Ruben Bridgewater PR-URL: #15308
Notable Changes * build: * Snapshots are now re-enabled in V8 #14875 * console: * Implement minimal `console.group()`. #14910 * deps: * upgrade libuv to 1.14.1 #14866 * update nghttp2 to v1.25.0 #14955 * dns: * Add `verbatim` option to dns.lookup(). When true, results from the DNS resolver are passed on as-is, without the reshuffling that Node.js otherwise does that puts IPv4 addresses before IPv6 addresses. #14731 * fs: * add fs.copyFile and fs.copyFileSync which allows for more efficient copying of files. #15034 * inspector: * Enable async stack traces #13870 * module: * Add support for ESM. This is currently behind the `--experimental-modules` flag and requires the .mjs extension. `node --experimental-modules index.mjs` #14369 * napi: * implement promise #14365 * os: * Add support for CIDR notation to the output of the networkInterfaces() method. #14307 * perf_hooks: * An initial implementation of the Performance Timing API for Node.js. This is the same Performance Timing API implemented by modern browsers with a number of Node.js specific properties. The User Timing mark() and measure() APIs are implemented, as is a Node.js specific flavor of the Frame Timing for measuring event loop duration. #14680 * tls: * multiple PFX in createSecureContext [#14793](#14793) * Added new collaborators: * BridgeAR – Ruben Bridgewater PR-URL: #15308
Fixes: nodejs#14906 PR-URL: nodejs#15034 Reviewed-By: Timothy Gu <timothygu99@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Notable Changes * build: * Snapshots are now re-enabled in V8 nodejs#14875 * console: * Implement minimal `console.group()`. nodejs#14910 * deps: * upgrade libuv to 1.14.1 nodejs#14866 * update nghttp2 to v1.25.0 nodejs#14955 * dns: * Add `verbatim` option to dns.lookup(). When true, results from the DNS resolver are passed on as-is, without the reshuffling that Node.js otherwise does that puts IPv4 addresses before IPv6 addresses. nodejs#14731 * fs: * add fs.copyFile and fs.copyFileSync which allows for more efficient copying of files. nodejs#15034 * inspector: * Enable async stack traces nodejs#13870 * module: * Add support for ESM. This is currently behind the `--experimental-modules` flag and requires the .mjs extension. `node --experimental-modules index.mjs` nodejs#14369 * napi: * implement promise nodejs#14365 * os: * Add support for CIDR notation to the output of the networkInterfaces() method. nodejs#14307 * perf_hooks: * An initial implementation of the Performance Timing API for Node.js. This is the same Performance Timing API implemented by modern browsers with a number of Node.js specific properties. The User Timing mark() and measure() APIs are implemented, as is a Node.js specific flavor of the Frame Timing for measuring event loop duration. nodejs#14680 * tls: * multiple PFX in createSecureContext [nodejs#14793](nodejs#14793) * Added new collaborators: * BridgeAR – Ruben Bridgewater PR-URL: nodejs#15308
| Back | FazBrowse Home | New Git URL |
This PR adds fs.copyFile() and fs.copyFileSync().
Fixes: #14906
Checklist
Affected core subsystem(s)
fs