mirror of
https://github.com/nodejs/node.git
synced 2026-11-24 21:50:36 -05:00
fs: fix cp symlink and EEXIST handling on Windows
Fixes: https://github.com/nodejs/node/issues/59636 Signed-off-by: Kirill Saied <sayed.kirill@gmail.com> PR-URL: https://github.com/nodejs/node/pull/64353 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Stefan Stojanovic <stefan.stojanovic@janeasystems.com>
This commit is contained in:
1 parent
2a3babb8d7
commit
63321eeb11
2 files changed
+13
-3
No files matched your search
+13
-1
@@ -3680,6 +3680,12 @@ std::vector<std::string> normalizePathToArray(
|
||||
const std::filesystem::path& path) {
|
||||
std::vector<std::string> parts;
|
||||
std::filesystem::path absPath = std::filesystem::absolute(path);
|
||||
#ifdef _WIN32
|
||||
auto wstr = absPath.wstring();
|
||||
if (wstr.starts_with(L"\\\\?\\")) {
|
||||
absPath = std::filesystem::path(wstr.substr(4));
|
||||
}
|
||||
#endif
|
||||
for (const auto& part : absPath) {
|
||||
if (!part.empty()) parts.push_back(part.string());
|
||||
}
|
||||
@@ -3818,6 +3824,12 @@ static void CpSyncCopyDir(const FunctionCallbackInfo<Value>& args) {
|
||||
}
|
||||
auto symlink_target_absolute = std::filesystem::weakly_canonical(
|
||||
std::filesystem::absolute(src / symlink_target));
|
||||
#ifdef _WIN32
|
||||
auto wstr = symlink_target_absolute.wstring();
|
||||
if (wstr.starts_with(L"\\\\?\\")) {
|
||||
symlink_target_absolute = std::filesystem::path(wstr.substr(4));
|
||||
}
|
||||
#endif
|
||||
if (dir_entry.is_directory()) {
|
||||
std::filesystem::create_directory_symlink(
|
||||
symlink_target_absolute, dest_file_path, error);
|
||||
@@ -3841,7 +3853,7 @@ static void CpSyncCopyDir(const FunctionCallbackInfo<Value>& args) {
|
||||
std::filesystem::copy_file(
|
||||
dir_entry.path(), dest_file_path, file_copy_opts, error);
|
||||
if (error) {
|
||||
if (error.value() == EEXIST) {
|
||||
if (error == std::errc::file_exists) {
|
||||
THROW_ERR_FS_CP_EEXIST(isolate,
|
||||
"[ERR_FS_CP_EEXIST]: Target already exists: "
|
||||
"cp returned EEXIST (%s already exists)",
|
||||
|
||||
@@ -26,10 +26,8 @@ test-snapshot-reproducible: SKIP
|
||||
# https://github.com/nodejs/node/issues/59090
|
||||
test-inspector-network-fetch: PASS, FLAKY
|
||||
# https://github.com/nodejs/node/issues/59636
|
||||
test-fs-cp-sync-error-on-exist: SKIP
|
||||
test-fs-cp-sync-symlink-points-to-dest-error: SKIP
|
||||
test-fs-cp-async-symlink-points-to-dest: SKIP
|
||||
test-fs-cp-sync-unicode-folder-names: SKIP
|
||||
|
||||
# Windows on ARM
|
||||
[$system==win32 && $arch==arm64]
|
||||
|
||||
Reference in new issue
Block a user