Skip to content

Commit

Permalink
fs: add support for mode flag to specify the copy behavior
Browse files Browse the repository at this point in the history
`fs.copyFile()` supports copy-on-write operation
if the underlying platform supports it by passing a mode flag.
This behavior was added in
a16d88d.

This patch adds `mode` flag to `fs.cp()`, `fs.cpSync()`,
and `fsPromises.cp()` to allow to change their behaviors
to copy files.

This test case is based on the test case that was introduced
when we add `fs.constants.COPYFILE_FICLONE`.
a16d88d.

This test strategy is:

- If the platform supports copy-on-write operation,
  check whether the destination is expected
- Otherwise, the operation will fail
  and check whether the failure error information is expected.

Fixes: #47080
PR-URL: #47084
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
  • Loading branch information
tetsuharuohzeki authored and MoLow committed Jul 6, 2023
1 parent d9448b8 commit ed0b62c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -5158,7 +5158,7 @@ changes:
pr-url: https://github.com/nodejs/node/pull/47084
description: Accept an additional `mode` option to specify
the copy behavior as the `mode` argument of `fs.copyFile()`.
- version: v17.6.0
- version: v17.6.0
pr-url: https://github.com/nodejs/node/pull/41819
description: Accepts an additional `verbatimSymlinks` option to specify
whether to perform path resolution for symlinks.
Expand Down

0 comments on commit ed0b62c

Please sign in to comment.