Commit a54e898
fs: add support for mode flag to specify the copy behavior
`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>1 parent cfafe43 commit a54e898Copy full SHA for a54e898
File tree
Expand file treeCollapse file tree
5 files changed
+127
-2
lines changedOpen diff view settings
Filter options
- doc/api
- lib/internal/fs
- cp
- test/parallel
Expand file treeCollapse file tree
5 files changed
+127
-2
lines changedOpen diff view settings
Collapse file
+20Lines changed: 20 additions & 0 deletions
- Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
966 | 966 | |
967 | 967 | |
968 | 968 | |
| 969 | + |
| 970 | + |
| 971 | + |
| 972 | + |
969 | 973 | |
970 | 974 | |
971 | 975 | |
| ||
992 | 996 | |
993 | 997 | |
994 | 998 | |
| 999 | + |
| 1000 | + |
995 | 1001 | |
996 | 1002 | |
997 | 1003 | |
| ||
2286 | 2292 | |
2287 | 2293 | |
2288 | 2294 | |
| 2295 | + |
| 2296 | + |
| 2297 | + |
| 2298 | + |
2289 | 2299 | |
2290 | 2300 | |
2291 | 2301 | |
| ||
2317 | 2327 | |
2318 | 2328 | |
2319 | 2329 | |
| 2330 | + |
| 2331 | + |
2320 | 2332 | |
2321 | 2333 | |
2322 | 2334 | |
| ||
5191 | 5203 | |
5192 | 5204 | |
5193 | 5205 | |
| 5206 | + |
| 5207 | + |
| 5208 | + |
| 5209 | + |
5194 | 5210 | |
5195 | 5211 | |
5196 | 5212 | |
| ||
5216 | 5232 | |
5217 | 5233 | |
5218 | 5234 | |
| 5235 | + |
| 5236 | + |
5219 | 5237 | |
5220 | 5238 | |
5221 | 5239 | |
| ||
8004 | 8022 | |
8005 | 8023 | |
8006 | 8024 | |
| 8025 | + |
8007 | 8026 | |
8008 | 8027 | |
8009 | 8028 | |
| ||
8037 | 8056 | |
8038 | 8057 | |
8039 | 8058 | |
| 8059 | + |
8040 | 8060 | |
8041 | 8061 | |
8042 | 8062 | |
|
Collapse file
lib/internal/fs/cp/cp-sync.js
Copy file name to clipboardExpand all lines: lib/internal/fs/cp/cp-sync.js+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
226 | 226 | |
227 | 227 | |
228 | 228 | |
229 | | - |
| 229 | + |
230 | 230 | |
231 | 231 | |
232 | 232 | |
|
Collapse file
+1-1Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
257 | 257 | |
258 | 258 | |
259 | 259 | |
260 | | - |
| 260 | + |
261 | 261 | |
262 | 262 | |
263 | 263 | |
|
Collapse file
+1Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
787 | 787 | |
788 | 788 | |
789 | 789 | |
| 790 | + |
790 | 791 | |
791 | 792 | |
792 | 793 | |
|
Collapse file
test/parallel/test-fs-cp.mjs
Copy file name to clipboardExpand all lines: test/parallel/test-fs-cp.mjs+104Lines changed: 104 additions & 0 deletions
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
38 | 38 | |
39 | 39 | |
40 | 40 | |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | + |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | + |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | + |
41 | 65 | |
42 | 66 | |
43 | 67 | |
| ||
107 | 131 | |
108 | 132 | |
109 | 133 | |
| 134 | + |
| 135 | + |
| 136 | + |
| 137 | + |
| 138 | + |
| 139 | + |
| 140 | + |
| 141 | + |
110 | 142 | |
111 | 143 | |
112 | 144 | |
| ||
425 | 457 | |
426 | 458 | |
427 | 459 | |
| 460 | + |
| 461 | + |
| 462 | + |
| 463 | + |
| 464 | + |
| 465 | + |
| 466 | + |
| 467 | + |
| 468 | + |
| 469 | + |
| 470 | + |
| 471 | + |
| 472 | + |
| 473 | + |
| 474 | + |
| 475 | + |
| 476 | + |
| 477 | + |
| 478 | + |
| 479 | + |
| 480 | + |
| 481 | + |
| 482 | + |
| 483 | + |
| 484 | + |
428 | 485 | |
429 | 486 | |
430 | 487 | |
| ||
799 | 856 | |
800 | 857 | |
801 | 858 | |
| 859 | + |
| 860 | + |
| 861 | + |
| 862 | + |
| 863 | + |
| 864 | + |
| 865 | + |
| 866 | + |
802 | 867 | |
803 | 868 | |
804 | 869 | |
| ||
810 | 875 | |
811 | 876 | |
812 | 877 | |
| 878 | + |
| 879 | + |
| 880 | + |
| 881 | + |
| 882 | + |
| 883 | + |
| 884 | + |
| 885 | + |
| 886 | + |
| 887 | + |
| 888 | + |
| 889 | + |
| 890 | + |
| 891 | + |
| 892 | + |
| 893 | + |
| 894 | + |
| 895 | + |
| 896 | + |
| 897 | + |
| 898 | + |
| 899 | + |
| 900 | + |
| 901 | + |
| 902 | + |
| 903 | + |
| 904 | + |
| 905 | + |
| 906 | + |
813 | 907 | |
814 | 908 | |
815 | 909 | |
| ||
847 | 941 | |
848 | 942 | |
849 | 943 | |
| 944 | + |
| 945 | + |
| 946 | + |
| 947 | + |
| 948 | + |
| 949 | + |
| 950 | + |
| 951 | + |
| 952 | + |
| 953 | + |
850 | 954 | |
851 | 955 | |
852 | 956 | |
|
0 commit comments