FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fs: fix `fs.rm` support for loop symlinks by nathanael-ruf · Pull Request #45439 · nodejs/node · GitHub

/ node Public

fs: fix fs.rm support for loop symlinks - #45439

Merged
nodejs-github-bot merged 4 commits into
nodejs:mainfrom
nathanael-ruf:fs-rm-sym
Nov 18, 2022
Merged

fs: fix fs.rm support for loop symlinks#45439
nodejs-github-bot merged 4 commits into
nodejs:mainfrom
nathanael-ruf:fs-rm-sym

Conversation

nathanael-ruf commented Nov 12, 2022
edited
Loading

Copy link
Copy Markdown
Contributor

Fixes: #45404

nodejs-github-bot added fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run. labels Nov 12, 2022

Copy link
Copy Markdown
Contributor Author

The tests have quite a bit of duplicated code (both existing and my new tests). I can add a new block at the bottom of the file that adds the new tests for the sync, async and promise version without so much duplicated code if you want.

anonrig added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 12, 2022
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 12, 2022

This comment was marked as outdated.

Trott commented Nov 12, 2022

Copy link
Copy Markdown
Member

The tests have quite a bit of duplicated code (both existing and my new tests). I can add a new block at the bottom of the file that adds the new tests for the sync, async and promise version without so much duplicated code if you want.

For tests only, I generally prefer the repetition. (Ref: https://stackoverflow.com/a/11837973/436641)

Trott added request-ci Add this label to start a Jenkins CI on a PR. and removed request-ci Add this label to start a Jenkins CI on a PR. labels Nov 12, 2022
aduh95 changed the title fs: fix deleting invalid/loop symlinks. add tests. fs: fix fs.rm support for loop symlinks Nov 12, 2022
Trott added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 12, 2022
Comment thread test/parallel/test-fs-rm.js Outdated
Comment thread test/parallel/test-fs-rm.js Outdated
aduh95 removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 12, 2022

nathanael-ruf commented Nov 13, 2022
edited
Loading

Copy link
Copy Markdown
Contributor Author

Thanks for fixing the commit message, one question though: For something like addressing the review comments, should I always amend and force push or is another commit okay for this (I guess you can always squash at the end)?

Also I think the title of the PR is no longer 100% accurate, because deleting invalid links was also broken before (the stat call failed with ENOENT):

nathanael ~/tmp λ tree
.
└── b -> a

nathanael ~/tmp λ node -e 'fs.rmSync("b")'
node:internal/fs/utils:344
    throw err;
    ^

Error: ENOENT: no such file or directory, stat 'b'
    at Object.statSync (node:fs:1538:3)
    at __node_internal_ (node:internal/fs/utils:793:8)
    at Object.rmSync (node:fs:1213:13)
    at [eval]:1:4
    at Script.runInThisContext (node:vm:129:12)
    at Object.runInThisContext (node:vm:305:38)
    at node:internal/process/execution:76:19
    at [eval]-wrapper:6:22
    at evalScript (node:internal/process/execution:75:60)
    at node:internal/main/eval_string:27:3 {
  errno: -2,
  syscall: 'stat',
  code: 'ENOENT',
  path: 'b'
}

The loop thing was just the first issue I encountered.

aduh95 commented Nov 13, 2022 via email

Copy link
Copy Markdown
Contributor

aduh95 commented Nov 13, 2022

Copy link
Copy Markdown
Contributor

/cc @nodejs/fs

aduh95 added author ready PRs that have at least one approval, no outstanding review comments, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Nov 13, 2022
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 13, 2022

This comment was marked as outdated.

This comment was marked as outdated.

LiviaMedeiros left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM with a suggestion.

Copy link
Copy Markdown
Contributor Author

Looks like existsSync (and therefore access) returns false on an invalid symlink (see my last commit). Is this also a bug or intended behaviour?

LiviaMedeiros commented Nov 14, 2022
edited
Loading

Copy link
Copy Markdown
Member

Looks like existsSync (and therefore access) returns false on an invalid symlink (see my last commit). Is this also a bug or intended behaviour?

I think this is intended. In general, symlinks are supposed to be transparent, so accessing invalid symlink should be equal to accessing its destination (e.g. nonexistent file).

Testing if broken symlink still exists can be performed explicitly with lstat instead.
Alternatively, improvements to access (like optional argument { verbatimSymlinks: false }) might also be considered.

LiviaMedeiros added request-ci Add this label to start a Jenkins CI on a PR. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. labels Nov 14, 2022
github-actions Bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 14, 2022

This comment was marked as outdated.

This comment was marked as outdated.

This comment was marked as outdated.

Copy link
Copy Markdown
Collaborator

LiviaMedeiros added the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 18, 2022
nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 18, 2022
nodejs-github-bot merged commit 6f9175d into nodejs:main Nov 18, 2022

Copy link
Copy Markdown
Collaborator

Landed in 6f9175d

Copy link
Copy Markdown
Member

Thanks for the contribution!

ruyadorno pushed a commit that referenced this pull request Nov 21, 2022
Fixes: #45404
PR-URL: #45439
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
ruyadorno mentioned this pull request Nov 24, 2022
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
Fixes: #45404
PR-URL: #45439
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
danielleadams pushed a commit that referenced this pull request Jan 3, 2023
Fixes: #45404
PR-URL: #45439
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
Reviewed-By: LiviaMedeiros <livia@cirno.name>
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author ready PRs that have at least one approval, no outstanding review comments, and a CI started. commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. fs Issues and PRs related to the fs subsystem / file system. needs-ci PRs that need a full CI run.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fs.rm cannot delete a symlink which is part of a loop

7 participants


Back | FazBrowse Home | New Git URL