Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

src: revert filesystem::path changes #55015

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

anonrig
Copy link
Member

@anonrig anonrig commented Sep 19, 2024

Reverts #53063. There are still some filesystem::path references left, since they're added in multiple different PRs. Depending on whether we need them or not, we can remove them.

We're reverting because it fixes multiple different regressions due to Windows UTF-16 path requirements.

Fixes #54991
Fixes #54476

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/security-wg

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. labels Sep 19, 2024
@anonrig anonrig force-pushed the revert-filesystem-path branch 3 times, most recently from eea22f7 to 37bd2dc Compare September 19, 2024 17:17
@anonrig anonrig force-pushed the revert-filesystem-path branch 2 times, most recently from be2b0b8 to b0e83d9 Compare September 19, 2024 17:21
@anonrig
Copy link
Member Author

anonrig commented Sep 19, 2024

@joyeecheung Can you double check the changes on compile_cache.cc and header file? I manually had to change those lines, there was a conflict.

auto file_status = std::filesystem::status(path);
if (file_status.type() == std::filesystem::file_type::directory) {
path /= "*";
uv_fs_t req;
Copy link
Member Author

Choose a reason for hiding this comment

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

@joyeecheung Is it safe to keep this function, or do we need this revert?

Copy link
Member

@joyeecheung joyeecheung Sep 20, 2024

Choose a reason for hiding this comment

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

Is std::filesystem::path(res) correct? From what I can tell, res contains UTF8-encoded data, and it's about to be passed into uv_fs_stat which also expects UTF8-encoded data. So std::filesystem::path(res) here is also going to crash on Windows when res contains code points that are encoded differently in UTF16 unless it's casted between u8string both ways.

@RedYetiDev RedYetiDev added fs Issues and PRs related to the fs subsystem / file system. revert PRs that revert previously landed PRs. labels Sep 19, 2024
@RedYetiDev
Copy link
Member

Is it possible to add a test for those issues?

Copy link

codecov bot commented Sep 19, 2024

Codecov Report

Attention: Patch coverage is 93.54839% with 2 lines in your changes missing coverage. Please review.

Project coverage is 88.04%. Comparing base (291d90a) to head (ba26f0b).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/env.cc 50.00% 1 Missing ⚠️
src/node_modules.cc 75.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #55015   +/-   ##
=======================================
  Coverage   88.04%   88.04%           
=======================================
  Files         652      652           
  Lines      183764   183760    -4     
  Branches    35862    35863    +1     
=======================================
  Hits       161787   161787           
+ Misses      15233    15230    -3     
+ Partials     6744     6743    -1     
Files with missing lines Coverage Δ
src/compile_cache.cc 79.59% <100.00%> (-0.41%) ⬇️
src/compile_cache.h 100.00% <100.00%> (ø)
src/inspector_profiler.cc 78.79% <100.00%> (+0.26%) ⬆️
src/node_file.cc 77.03% <100.00%> (-0.02%) ⬇️
src/node_report.cc 93.15% <100.00%> (ø)
src/path.cc 67.39% <100.00%> (ø)
src/permission/fs_permission.cc 73.22% <100.00%> (+1.68%) ⬆️
src/permission/fs_permission.h 91.80% <100.00%> (ø)
src/util.h 89.91% <ø> (ø)
src/env.cc 85.58% <50.00%> (-0.02%) ⬇️
... and 1 more

... and 29 files with indirect coverage changes

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@joyeecheung joyeecheung left a comment

Choose a reason for hiding this comment

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

LGTM % nits

std::u8string cache_dir_with_tag_u8 = cache_dir_with_tag.u8string();
std::string cache_dir_with_tag_str(cache_dir_with_tag_u8.begin(),
cache_dir_with_tag_u8.end());
std::string cache_dir_with_tag =
Copy link
Member

Choose a reason for hiding this comment

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

You can minimize the diff/potential conflicts if this is named as cache_dir_with_tag_str

@joyeecheung
Copy link
Member

joyeecheung commented Sep 20, 2024

By the way I don't think this fixes #54476 because fs.cpSync changes were done in #53614 and #54653 is fixing that with the casting, as the path is going to be consumed by std::filesystem::create_directories at the end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to the fs subsystem / file system. lib / src Issues and PRs related to general changes in the lib or src directory. needs-ci PRs that need a full CI run. revert PRs that revert previously landed PRs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

v22.3.0 Cannot start if the folder is Unicode. v22.6.0 fs.cpSync crash
5 participants