From 6b76c382117f5551b90507cea9121c9cbd500e60 Mon Sep 17 00:00:00 2001 From: Ben Bridle Date: Sat, 1 Feb 2025 17:25:42 +1300 Subject: Only copy modified files When copying a file, if a file already exists at the destination path with the same last-modified date and the same size, the file is not copied. --- src/entry.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/entry.rs') diff --git a/src/entry.rs b/src/entry.rs index 72eeb7e..1b6b577 100644 --- a/src/entry.rs +++ b/src/entry.rs @@ -1,6 +1,9 @@ -use std::path::{Path, PathBuf}; use crate::*; +use std::path::{Path, PathBuf}; +use std::time::SystemTime; + + #[derive(PartialEq)] pub enum EntryType { File, @@ -17,6 +20,8 @@ pub struct Entry { pub path: PathBuf, /// The file path as originally presented to the [Entry] constructor. pub original_path: PathBuf, + /// Not available on all platforms. + pub last_modified: Option, } impl Entry { @@ -51,6 +56,7 @@ impl Entry { path: canonical_path, original_path: path.to_path_buf(), is_symlink: metadata.is_symlink(), + last_modified: metadata.modified().ok(), }) } -- cgit v1.2.3-70-g09d2