GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fs: respect dereference when copy symlink directory · nodejs/node@ee89c31

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src
    • node_file.cc
  • test/parallel
    • test-fs-cp.mjs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/node_file.cc‎

Copy file name to clipboardExpand all lines: src/node_file.cc
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3060,7 +3060,9 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& args) {
30603060

30613061
bool dest_exists = !error_code && dest_status.type() !=
30623062
std::filesystem::file_type::not_found;
3063-
bool src_is_dir = src_status.type() == std::filesystem::file_type::directory;
3063+
bool src_is_dir =
3064+
(src_status.type() == std::filesystem::file_type::directory) ||
3065+
(dereference && src_status.type() == std::filesystem::file_type::symlink);
30643066

30653067
if (!error_code) {
30663068
// Check if src and dest are identical.
Collapse file

‎test/parallel/test-fs-cp.mjs‎

Copy file name to clipboardExpand all lines: test/parallel/test-fs-cp.mjs
+17Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,23 @@ function nextdir() {
119119
}
120120

121121

122+
// It overrides target directory with what symlink points to, when dereference is true.
123+
{
124+
const src = nextdir();
125+
const symlink = nextdir();
126+
const dest = nextdir();
127+
mkdirSync(src, mustNotMutateObjectDeep({ recursive: true }));
128+
writeFileSync(join(src, 'foo.js'), 'foo', 'utf8');
129+
symlinkSync(src, symlink);
130+
131+
mkdirSync(dest, mustNotMutateObjectDeep({ recursive: true }));
132+
133+
cpSync(symlink, dest, mustNotMutateObjectDeep({ dereference: true, recursive: true }));
134+
const destStat = lstatSync(dest);
135+
assert(!destStat.isSymbolicLink());
136+
assertDirEquivalent(src, dest);
137+
}
138+
122139
// It throws error when verbatimSymlinks is not a boolean.
123140
{
124141
const src = './test/fixtures/copy/kitchen-sink';

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.