Skip to content

fs: implement lutimes - #33399

Closed
arcanis wants to merge 1 commit into
nodejs:masterfrom
arcanis:mael/lutimes
Closed

arcanis wants to merge 1 commit into
nodejs:masterfrom
arcanis:mael/lutimes

Conversation

@arcanis

@arcanis arcanis commented May 14, 2020

Copy link
Copy Markdown
Contributor
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

The FS API is currently lacking support for utimes, which makes it difficult to implement perfect copy mechanisms (since we can't ensure that we'll be able to preserve the atime/mtime from the original file). This got recently fixed in libuv (libuv/libuv@bd42923), and this PR adds the required binding.

@nodejs-github-bot nodejs-github-bot added c++ Issues and PRs that require attention from people who are familiar with C++. fs Issues and PRs related to file-system APIs and the fs module. labels May 14, 2020
@addaleax addaleax added the semver-minor PRs that contain new features and should be released in the next minor version. label May 14, 2020
Comment thread doc/api/fs.md Resolved
Comment thread doc/api/fs.md Resolved

ghost 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.

LGTM but less duplication would be good.

Comment thread src/node_file.cc Outdated

ghost May 14, 2020

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.

It'd be nicer to share this code with UTimes(). The JS bindings too, although that's not as much code.

The FS_SYNC_TRACE_BEGIN/FS_SYNC_TRACE_END labels are off, by the way.

ghost May 14, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried to keep roughly the same pattern as for lchown and lchmod, which are both duplicated similarly.

Will update the traces 👍

ghost May 14, 2020

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.

Yes, but remember the rule of three: duplicating something once? Probably okay. Duplicating it twice? Time to refactor.

Comment thread doc/api/fs.md Resolved
Comment thread doc/api/fs.md Outdated

ghost May 14, 2020

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.

We should explain what this method does here and link to the man page for lutimes. I think taking the description from the manual page should be fine:

fs.lutimes() changes the access and modification times of a file in the same way as fs.utimes, with the difference that if filename refers to a symbolic link, then the link is not dereferenced: instead, the timestamps of the symbolic link are changed.

Or something similar - and other references (like the synchronous version) should reference the decsription.

Comment thread doc/api/fs.md Resolved

ghost 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.

Hey thank you for this. Not blocking on this and I am thankful for this PR :]

I would really prefer it if we:

  • Addressed the docs issues and improve the documentation before landing so users understand this.
  • Add more tests that cover the entire API surface (passing invalid mtimes and modes looked checked but what about passing a url as path? etc)

ghost 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.

LGTM to me overall, but as others have commented, docs and tests could be expanded a bit more.

@benjamingr

ghost commented May 14, 2020

Copy link
Copy Markdown
Member

Docs look much better now (tests could still use some love)

Comment thread doc/api/fs.md Resolved
@arcanis

ghost commented May 14, 2020

Copy link
Copy Markdown
Contributor Author

I fixed the tests, and made them run on URL instances as well as paths.

Btw, I don't know if there's a trick I need to configure, but running the tests is ... painful 😢
image

@richardlau

ghost commented May 14, 2020

Copy link
Copy Markdown
Member

@arcanis BUILDING.md#building-nodejs-1 mentions the script in tools/macos-firewall.sh. (I don't use a mac so can't personally vouch for the script but I assume there are other collaborators who do use it.)

@cjihrig

ghost commented May 14, 2020

Copy link
Copy Markdown
Contributor

I use that firewall script. It does the trick of stopping those popups. My only issue with it has been that you occasionally need to re-run it.

Comment thread doc/api/fs.md Resolved
Comment thread doc/api/fs.md Resolved
Comment thread lib/fs.js Resolved
@nodejs-github-bot

ghost commented May 19, 2020

Copy link
Copy Markdown
Collaborator

@juanarbol juanarbol added the author ready PRs with CI started, the required approvals, and no outstanding review comments. label May 19, 2020
@addaleax addaleax removed the author ready PRs with CI started, the required approvals, and no outstanding review comments. label May 19, 2020
@addaleax

ghost commented May 19, 2020 •

Copy link
Copy Markdown
Member

@arcanis Can you remove the merge commit and rebase instead? Merge conflicts break our CI. Otherwise this should be good to go 👍

@BridgeAR

ghost commented May 27, 2020

Copy link
Copy Markdown
Member

Ping @arcanis

@BridgeAR
BridgeAR force-pushed the master branch 2 times, most recently from 8ae28ff to 2935f72 Compare May 31, 2020 12:18
@addaleax

ghost commented Sep 23, 2020 •

Copy link
Copy Markdown
Member

If this should be landed on Node 12.x, it needs a manual backport

Edit: nvm, the conflicts are so small I did it directly: #35320

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 file-system APIs and the fs module. semver-minor PRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.