| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent c003370 commit 8997e69
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3052,7 +3052,14 @@ static void CpSyncCheckPaths(const FunctionCallbackInfo<Value>& args) { | |||
| 3052 | 3052 | ? std::filesystem::symlink_status(src_path, error_code) | |
| 3053 | 3053 | : std::filesystem::status(src_path, error_code); | |
| 3054 | 3054 | if (error_code) { | |
| 3055 | - return env->ThrowUVException(EEXIST, "lstat", nullptr, src.out()); | ||
| 3055 | + #ifdef _WIN32 | ||
| 3056 | + int errorno = uv_translate_sys_error(error_code.value()); | ||
| 3057 | + #else | ||
| 3058 | + int errorno = | ||
| 3059 | + error_code.value() > 0 ? -error_code.value() : error_code.value(); | ||
| 3060 | + #endif | ||
| 3061 | + return env->ThrowUVException( | ||
| 3062 | + errorno, dereference ? "stat" : "lstat", nullptr, src.out()); | ||
| 3056 | 3063 | } | |
| 3057 | 3064 | auto dest_status = | |
| 3058 | 3065 | dereference ? std::filesystem::symlink_status(dest_path, error_code) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -419,6 +419,26 @@ if (!isWindows) { | |||
| 419 | 419 | ); | |
| 420 | 420 | } | |
| 421 | 421 | ||
| 422 | + // It throws an error when attempting to copy a file with a name that is too long. | ||
| 423 | + { | ||
| 424 | + const src = 'a'.repeat(5000); | ||
| 425 | + const dest = nextdir(); | ||
| 426 | + assert.throws( | ||
| 427 | + () => cpSync(src, dest), | ||
| 428 | + { code: isWindows ? 'ENOENT' : 'ENAMETOOLONG' } | ||
| 429 | + ); | ||
| 430 | + } | ||
| 431 | + | ||
| 432 | + // It throws an error when attempting to copy a dir that does not exist. | ||
| 433 | + { | ||
| 434 | + const src = nextdir(); | ||
| 435 | + const dest = nextdir(); | ||
| 436 | + assert.throws( | ||
| 437 | + () => cpSync(src, dest, mustNotMutateObjectDeep({ recursive: true })), | ||
| 438 | + { code: 'ENOENT' } | ||
| 439 | + ); | ||
| 440 | + } | ||
| 441 | + | ||
| 422 | 442 | // It makes file writeable when updating timestamp, if not writeable. | |
| 423 | 443 | { | |
| 424 | 444 | const src = nextdir(); | |
| Back | FazBrowse Home | New Git URL |
0 commit comments