File tree Expand file tree Collapse file tree 4 files changed +11
-10
lines changed Expand file tree Collapse file tree 4 files changed +11
-10
lines changed Original file line number Diff line number Diff line change @@ -924,7 +924,7 @@ changes:
924
924
operation. It is possible to create a mask consisting of the bitwise OR of
925
925
two or more values (e.g.
926
926
` fs .constants .COPYFILE_EXCL | fs .constants .COPYFILE_FICLONE ` )
927
- **Default:** ` 0 ` .
927
+ **Default:** ` fs . constants . COPYFILE_FICLONE ` .
928
928
* ` fs .constants .COPYFILE_EXCL ` : The copy operation will fail if ` dest`
929
929
already exists.
930
930
* ` fs .constants .COPYFILE_FICLONE ` : The copy operation will attempt to create
@@ -5187,7 +5187,7 @@ changes:
5187
5187
5188
5188
* ` src` {string| Buffer| URL } source filename to copy
5189
5189
* ` dest` {string| Buffer| URL } destination filename of the copy operation
5190
- * ` mode` {integer} modifiers for copy operation. ** Default: ** ` 0 ` .
5190
+ * ` mode` {integer} modifiers for copy operation. ** Default: ** ` fs.constants.COPYFILE_FICLONE ` .
5191
5191
5192
5192
Synchronously copies ` src` to ` dest` . By default, ` dest` is overwritten if it
5193
5193
already exists . Returns ` undefined` . Node .js makes no guarantees about the
Original file line number Diff line number Diff line change @@ -92,6 +92,7 @@ const {
92
92
} = require ( 'internal/util' ) ;
93
93
const {
94
94
constants : {
95
+ kDefaultCopyMode,
95
96
kIoMaxLength,
96
97
kMaxUserId,
97
98
} ,
@@ -2942,7 +2943,7 @@ function mkdtempSync(prefix, options) {
2942
2943
function copyFile ( src , dest , mode , callback ) {
2943
2944
if ( typeof mode === 'function' ) {
2944
2945
callback = mode ;
2945
- mode = 0 ;
2946
+ mode = kDefaultCopyMode ;
2946
2947
}
2947
2948
2948
2949
src = getValidatedPath ( src , 'src' ) ;
Original file line number Diff line number Diff line change @@ -112,16 +112,11 @@ const {
112
112
const kMinimumAccessMode = MathMin ( F_OK , W_OK , R_OK , X_OK ) ;
113
113
const kMaximumAccessMode = F_OK | W_OK | R_OK | X_OK ;
114
114
115
- const kDefaultCopyMode = 0 ;
115
+ const kDefaultCopyMode = COPYFILE_FICLONE ;
116
116
// The copy modes can be any of COPYFILE_EXCL, COPYFILE_FICLONE or
117
117
// COPYFILE_FICLONE_FORCE. They can be used in combination as well
118
118
// (COPYFILE_EXCL | COPYFILE_FICLONE | COPYFILE_FICLONE_FORCE).
119
- const kMinimumCopyMode = MathMin (
120
- kDefaultCopyMode ,
121
- COPYFILE_EXCL ,
122
- COPYFILE_FICLONE ,
123
- COPYFILE_FICLONE_FORCE ,
124
- ) ;
119
+ const kMinimumCopyMode = 0 ;
125
120
const kMaximumCopyMode = COPYFILE_EXCL |
126
121
COPYFILE_FICLONE |
127
122
COPYFILE_FICLONE_FORCE ;
@@ -927,6 +922,7 @@ const validatePosition = hideStackFrames((position, name) => {
927
922
928
923
module . exports = {
929
924
constants : {
925
+ kDefaultCopyMode,
930
926
kIoMaxLength,
931
927
kMaxUserId,
932
928
kReadFileBufferLength,
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ const tmpdir = require('../common/tmpdir');
6
6
const assert = require ( 'assert' ) ;
7
7
const fs = require ( 'fs' ) ;
8
8
const { internalBinding } = require ( 'internal/test/binding' ) ;
9
+ const { getValidMode } = require ( 'internal/fs/utils' ) ;
9
10
const {
10
11
UV_ENOENT ,
11
12
UV_EEXIST
@@ -61,6 +62,9 @@ fs.unlinkSync(dest);
61
62
fs . copyFileSync ( src , dest , UV_FS_COPYFILE_FICLONE ) ;
62
63
verify ( src , dest ) ;
63
64
65
+ // Verify that default mode is COPYFILE_FICLONE.
66
+ assert . strictEqual ( getValidMode ( null , 'copyFile' ) , COPYFILE_FICLONE ) ;
67
+
64
68
// Verify that COPYFILE_FICLONE_FORCE can be used.
65
69
try {
66
70
fs . unlinkSync ( dest ) ;
You can’t perform that action at this time.
0 commit comments