Skip to content

utimes should support undefined arguments to leave the time alone #56492

Open
@hoodmane

Description

@hoodmane

What is the problem this feature will solve?

Sometimes one only wants to modify access time, not modification time or vice versa.

I'm working on the Emscripten where we have an implementation of a linux file system backed by the node fs module. The utimens family of functions are supposed to leave the time value alone if UTIME_OMIT is passed in the nanosecond field.

What is the feature you are proposing to solve the problem?

It would be convenient if FS.utime(path, atime, undefined) would update the atime and leave the mtime alone, and vice versa.

node uses libuv to call utimens itself, but the libuv api only takes doubles and converts from them to fill the tv_nsec struct with uv__fs_to_timeval. It's not possible to make a double that is converted to UTIME_OMIT because uv__fs_to_timeval rounds the nanosecond field: https://github.com/libuv/libuv/blame/v1.x/src/unix/fs.c#L216. So libuv would need to be updated to support this. At the same time it could also be changed to support higher precision times #50859.

What alternatives have you considered?

Stat the file and use the stat to fill the time I want unchanged. Because of #50859, this will round trip the time through a double and so leave it only approximately unchanged not exactly unchanged.

Metadata

Metadata

Assignees

Labels

feature requestIssues that request new features to be added to Node.js.libuvIssues and PRs related to the libuv dependency or the uv binding.

Type

No type

Projects

Status

Awaiting Triage

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions