| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 0748160 commit e69be56
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3251,8 +3251,8 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& args) { | |||
| 3251 | 3251 | errorno, dereference ? "stat" : "lstat", nullptr, src.out()); | |
| 3252 | 3252 | } | |
| 3253 | 3253 | auto dest_status = | |
| 3254 | - dereference ? std::filesystem::symlink_status(dest_path, error_code) | ||
| 3255 | - : std::filesystem::status(dest_path, error_code); | ||
| 3254 | + dereference ? std::filesystem::status(dest_path, error_code) | ||
| 3255 | + : std::filesystem::symlink_status(dest_path, error_code); | ||
| 3256 | 3256 | ||
| 3257 | 3257 | bool dest_exists = !error_code && dest_status.type() != | |
| 3258 | 3258 | std::filesystem::file_type::not_found; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,50 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + // Refs: https://github.com/nodejs/node/issues/58939 | ||
| 4 | + // | ||
| 5 | + // In this test, both the cp and cpSync functions are attempting to copy | ||
| 6 | + // a file over a symlinked directory. | ||
| 7 | + | ||
| 8 | + const common = require('../common'); | ||
| 9 | + | ||
| 10 | + const { | ||
| 11 | + cp, | ||
| 12 | + cpSync, | ||
| 13 | + mkdirSync, | ||
| 14 | + symlinkSync, | ||
| 15 | + writeFileSync, | ||
| 16 | + readFileSync, | ||
| 17 | + statSync | ||
| 18 | + } = require('fs'); | ||
| 19 | + | ||
| 20 | + const { | ||
| 21 | + join, | ||
| 22 | + } = require('path'); | ||
| 23 | + | ||
| 24 | + const assert = require('assert'); | ||
| 25 | + | ||
| 26 | + const tmpdir = require('../common/tmpdir'); | ||
| 27 | + tmpdir.refresh(); | ||
| 28 | + | ||
| 29 | + const pathA = join(tmpdir.path, 'a'); // file | ||
| 30 | + const pathB = join(tmpdir.path, 'b'); // directory | ||
| 31 | + const pathC = join(tmpdir.path, 'c'); // c -> b | ||
| 32 | + const pathD = join(tmpdir.path, 'd'); // d -> b | ||
| 33 | + | ||
| 34 | + writeFileSync(pathA, 'file a'); | ||
| 35 | + mkdirSync(pathB); | ||
| 36 | + symlinkSync(pathB, pathC, 'dir'); | ||
| 37 | + symlinkSync(pathB, pathD, 'dir'); | ||
| 38 | + | ||
| 39 | + cp(pathA, pathD, { dereference: false }, common.mustSucceed(() => { | ||
| 40 | + // The path d is now a file, not a symlink | ||
| 41 | + assert.strictEqual(readFileSync(pathA, 'utf-8'), readFileSync(pathD, 'utf-8')); | ||
| 42 | + assert.ok(statSync(pathA).isFile()); | ||
| 43 | + assert.ok(statSync(pathD).isFile()); | ||
| 44 | + })); | ||
| 45 | + | ||
| 46 | + cpSync(pathA, pathC, { dereference: false }); | ||
| 47 | + | ||
| 48 | + assert.strictEqual(readFileSync(pathA, 'utf-8'), readFileSync(pathC, 'utf-8')); | ||
| 49 | + assert.ok(statSync(pathA).isFile()); | ||
| 50 | + assert.ok(statSync(pathC).isFile()); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments