Skip to content

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

Closed

Description

@arpankapoor

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?

Activity

  1. Darksonn commented on Feb 27, 2024

    @Darksonn
    Member

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-tokioArea: The main tokio crateC-feature-requestCategory: A feature request.M-fsModule: tokio/fs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions