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:
924924 operation. It is possible to create a mask consisting of the bitwise OR of
925925 two or more values (e.g.
926926 ` fs .constants .COPYFILE_EXCL | fs .constants .COPYFILE_FICLONE ` )
927- **Default:** ` 0 ` .
927+ **Default:** ` fs . constants . COPYFILE_FICLONE ` .
928928 * ` fs .constants .COPYFILE_EXCL ` : The copy operation will fail if ` dest`
929929 already exists.
930930 * ` fs .constants .COPYFILE_FICLONE ` : The copy operation will attempt to create
@@ -5187,7 +5187,7 @@ changes:
51875187
51885188* ` src` {string| Buffer| URL } source filename to copy
51895189* ` 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 ` .
51915191
51925192Synchronously copies ` src` to ` dest` . By default, ` dest` is overwritten if it
51935193already 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 {
9292} = require ( 'internal/util' ) ;
9393const {
9494 constants : {
95+ kDefaultCopyMode,
9596 kIoMaxLength,
9697 kMaxUserId,
9798 } ,
@@ -2942,7 +2943,7 @@ function mkdtempSync(prefix, options) {
29422943function copyFile ( src , dest , mode , callback ) {
29432944 if ( typeof mode === 'function' ) {
29442945 callback = mode ;
2945- mode = 0 ;
2946+ mode = kDefaultCopyMode ;
29462947 }
29472948
29482949 src = getValidatedPath ( src , 'src' ) ;
Original file line number Diff line number Diff line change @@ -112,16 +112,11 @@ const {
112112const kMinimumAccessMode = MathMin ( F_OK , W_OK , R_OK , X_OK ) ;
113113const kMaximumAccessMode = F_OK | W_OK | R_OK | X_OK ;
114114
115- const kDefaultCopyMode = 0 ;
115+ const kDefaultCopyMode = COPYFILE_FICLONE ;
116116// The copy modes can be any of COPYFILE_EXCL, COPYFILE_FICLONE or
117117// COPYFILE_FICLONE_FORCE. They can be used in combination as well
118118// (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 ;
125120const kMaximumCopyMode = COPYFILE_EXCL |
126121 COPYFILE_FICLONE |
127122 COPYFILE_FICLONE_FORCE ;
@@ -927,6 +922,7 @@ const validatePosition = hideStackFrames((position, name) => {
927922
928923module . exports = {
929924 constants : {
925+ kDefaultCopyMode,
930926 kIoMaxLength,
931927 kMaxUserId,
932928 kReadFileBufferLength,
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ const tmpdir = require('../common/tmpdir');
66const assert = require ( 'assert' ) ;
77const fs = require ( 'fs' ) ;
88const { internalBinding } = require ( 'internal/test/binding' ) ;
9+ const { getValidMode } = require ( 'internal/fs/utils' ) ;
910const {
1011 UV_ENOENT ,
1112 UV_EEXIST
@@ -61,6 +62,9 @@ fs.unlinkSync(dest);
6162fs . copyFileSync ( src , dest , UV_FS_COPYFILE_FICLONE ) ;
6263verify ( src , dest ) ;
6364
65+ // Verify that default mode is COPYFILE_FICLONE.
66+ assert . strictEqual ( getValidMode ( null , 'copyFile' ) , COPYFILE_FICLONE ) ;
67+
6468// Verify that COPYFILE_FICLONE_FORCE can be used.
6569try {
6670 fs . unlinkSync ( dest ) ;
You can’t perform that action at this time.
0 commit comments