From 97ea2762b2ef419689f732c7cad27648c7fc9088 Mon Sep 17 00:00:00 2001 From: DarkCat09 Date: Tue, 22 Oct 2024 16:25:48 +0400 Subject: [PATCH] feat: implement check_outdated --- src/main.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 83d9d13..717a6a5 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,5 +61,16 @@ fn get_dist_path( } fn check_outdated(src: impl AsRef, dst: impl AsRef) -> bool { - true // TODO + let up_to_date = dst + .as_ref() + .metadata() + .and_then(|meta| meta.modified()) + .is_ok_and(|dst_mtime| { + src.as_ref() + .metadata() + .and_then(|meta| meta.modified()) + .is_ok_and(|src_mtime| src_mtime <= dst_mtime) + }); + // either we cannot get metadata or src_mtime > dst_mtime (outdated) + !up_to_date }