Skip to content

Commit 6b1b314

Browse files
committed
fs: remove broken symlinks in rmSync
Use std::filesystem::symlink_status() instead of status() so rmSync does not follow symlinks when determining file type. This allows unlinking broken symlinks (and symlinks to directories) instead of treating them as not_found.
1 parent 71d4fcb commit 6b1b314

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/node_file.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1636,7 +1636,7 @@ static void RmSync(const FunctionCallbackInfo<Value>& args) {
16361636
env, permission::PermissionScope::kFileSystemWrite, path.ToStringView());
16371637
auto file_path = std::filesystem::path(path.ToStringView());
16381638
std::error_code error;
1639-
auto file_status = std::filesystem::status(file_path, error);
1639+
auto file_status = std::filesystem::symlink_status(file_path, error);
16401640

16411641
if (file_status.type() == std::filesystem::file_type::not_found) {
16421642
return;

0 commit comments

Comments
 (0)