skydive/
storage_local.rs

1use anyhow::Result;
2use chrono::{DateTime, Utc};
3
4use std::fs::metadata;
5use std::path::PathBuf;
6
7/// Get the update time of a file in the local filesystem.
8///
9/// # Arguments
10///
11/// * `path` - A reference to a `PathBuf` object representing the path to the file.
12///
13/// # Returns
14///
15/// A `DateTime<Utc>` object representing the update time of the file.
16///
17/// # Errors
18///
19/// This function returns an error if the file metadata cannot be accessed.
20///
21/// # Panics
22///
23/// This function panics if the file path is invalid.
24pub fn local_get_file_update_time(path: &PathBuf) -> Result<DateTime<Utc>> {
25    let metadata = metadata(path)?;
26    let modified_time = metadata.modified()?;
27
28    Ok(DateTime::<Utc>::from(modified_time))
29}