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

Add tokio version of std::fs::File::set_times #6368

Open
arpankapoor opened this issue Feb 27, 2024 · 1 comment
Open

Add tokio version of std::fs::File::set_times #6368

arpankapoor opened this issue Feb 27, 2024 · 1 comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-fs Module: tokio/fs S-blocked-on-msrv Status: need an MSRV bump to progress

Comments

@arpankapoor
Copy link

Is your feature request related to a problem? Please describe.
Need async functions to set file times.

Describe the solution you'd like
Add tokio versions of std::fs::File::set_times and std::fs::File::set_modified.

Describe alternatives you've considered
Either reopen the file using std::fs::File and use set_times or use the filetime crate on the path.

Additional context
The std versions were introduced in 1.75 and I see that the current tokio MSRV is 1.63. I'm guessing using something like rustversion for conditional compilation would be a no go? Is there any other way to add this besides waiting until the MSRV reaches 1.75?

@arpankapoor arpankapoor added A-tokio Area: The main tokio crate C-feature-request Category: A feature request. labels Feb 27, 2024
@Darksonn Darksonn added the M-fs Module: tokio/fs label Feb 27, 2024
@Darksonn
Copy link
Contributor

You can implement it yourself:

let std_file = file.into_std().await;
let file = tokio::task::spawn_blocking(move || {
    std_file.set_times(...)?;
    Ok(tokio::fs::File::from_std(std_file))
})??;

We'd rather not add this right now for the reasons you mentioned.

@maminrayej maminrayej added the S-blocked-on-msrv Status: need an MSRV bump to progress label Mar 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-feature-request Category: A feature request. M-fs Module: tokio/fs S-blocked-on-msrv Status: need an MSRV bump to progress
Projects
None yet
Development

No branches or pull requests

3 participants