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

NIOFileSystem: Provide API to set last-modified timestamp (ie: "touch") #2712

Open
sliemeobn opened this issue May 2, 2024 · 2 comments
Open

Comments

@sliemeobn
Copy link

Expected behavior

I can set the last-modified timestamp on a file via a simple NIOFileSystem API.

Actual behavior

No APIs exist to set timestamps on files or perform a simple "touch".


I am not sure how much control over the various file timestamps one would realistically need, but I find that setting the current time as last-modified is a common thing on server systems.

My concrete use case was a tiny service that periodically checks local certificate files (for TLS), renews them if required, and triggers a "config-reload" of a long-running traefik instance. The simplest (maybe only?) way to tell traefik to hot-reload its certificates is by touching the config file.

I ended up sys-calling into utime myself, but it would be a great fit for the NIOFileSystem APIs.

@FranzBusch
Copy link
Contributor

Thanks for opening this up. Going to tag @glbrntt here since he build most of the NIOFileSystem stuff.

@glbrntt
Copy link
Contributor

glbrntt commented May 14, 2024

Thanks for opening this issue, I think this is a reasonable API to add.

We likely want to add a new API to the WritableFileHandleProtocol which can be used to update the access and modification time of an open file. Under the hood this would use futimens.

From that base API we can then extend WritableFileHandleProtocol to have a 'touch' API which sets both access and modification times to the current time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants