Commit 3f0636d
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 6ab8927 commit 3f0636dCopy full SHA for 3f0636d
File tree
Expand file treeCollapse file tree
5 files changed
+128
-3
lines changedOpen diff view settings
Filter options
- doc/api
- lib/internal/fs
- cp
- test/parallel
Expand file treeCollapse file tree
5 files changed
+128
-3
lines changedOpen diff view settings
Collapse file
+21-1Lines changed: 21 additions & 1 deletion
- Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| ||
962 | 962 | |
963 | 963 | |
964 | 964 | |
| 965 | + |
| 966 | + |
| 967 | + |
| 968 | + |
965 | 969 | |
966 | 970 | |
967 | 971 | |
| ||
986 | 990 | |
987 | 991 | |
988 | 992 | |
| 993 | + |
| 994 | + |
989 | 995 | |
990 | 996 | |
991 | 997 | |
| ||
2269 | 2275 | |
2270 | 2276 | |
2271 | 2277 | |
| 2278 | + |
| 2279 | + |
| 2280 | + |
| 2281 | + |
2272 | 2282 | |
2273 | 2283 | |
2274 | 2284 | |
| ||
2298 | 2308 | |
2299 | 2309 | |
2300 | 2310 | |
| 2311 | + |
| 2312 | + |
2301 | 2313 | |
2302 | 2314 | |
2303 | 2315 | |
| ||
5120 | 5132 | |
5121 | 5133 | |
5122 | 5134 | |
5123 | | - |
| 5135 | + |
| 5136 | + |
| 5137 | + |
| 5138 | + |
| 5139 | + |
5124 | 5140 | |
5125 | 5141 | |
5126 | 5142 | |
| ||
5143 | 5159 | |
5144 | 5160 | |
5145 | 5161 | |
| 5162 | + |
| 5163 | + |
5146 | 5164 | |
5147 | 5165 | |
5148 | 5166 | |
| ||
7907 | 7925 | |
7908 | 7926 | |
7909 | 7927 | |
| 7928 | + |
7910 | 7929 | |
7911 | 7930 | |
7912 | 7931 | |
| ||
7940 | 7959 | |
7941 | 7960 | |
7942 | 7961 | |
| 7962 | + |
7943 | 7963 | |
7944 | 7964 | |
7945 | 7965 | |
|
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 |
|---|---|---|
| ||
774 | 774 | |
775 | 775 | |
776 | 776 | |
| 777 | + |
777 | 778 | |
778 | 779 | |
779 | 780 | |
|
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