diff --git a/src/utils.rs b/src/utils.rs index 1b600c1..e0592ef 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -55,11 +55,12 @@ pub fn do_write_line( pub fn get_modification_time(file_path: &str) -> String { use chrono::{DateTime, Local}; use std::fs; + use std::time::SystemTime; + + let modification_time: SystemTime = fs::metadata(file_path) + .and_then(|m| m.modified()) + .unwrap_or(SystemTime::now()); - let metadata = fs::metadata(file_path).expect("Failed to get metadata"); - let modification_time = metadata - .modified() - .expect("Failed to get modification time"); let modification_time: DateTime = modification_time.into(); let modification_time: String = modification_time .format("%Y-%m-%d %H:%M:%S%.9f %z")