From a88e765961b2af4f4c7b7c552cad0c1e895d9173 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 14 Jan 2026 11:17:00 -0700 Subject: [PATCH] Copy file times, fixes #1294 --- src/operation/recursive.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/src/operation/recursive.rs b/src/operation/recursive.rs index 5233028..4c19bc3 100644 --- a/src/operation/recursive.rs +++ b/src/operation/recursive.rs @@ -384,6 +384,34 @@ impl Op { buf_in = buf_out; } + let mut times = fs::FileTimes::new(); + { + use std::os::unix::prelude::MetadataExt; + log::info!("{}", metadata.mtime()); + } + if let Ok(time) = dbg!(metadata.modified()) { + times = times.set_modified(time); + } + if let Ok(time) = dbg!(metadata.accessed()) { + times = times.set_accessed(time); + } + //TODO: upstream set_times implementation to compio? + { + use compio::driver::{ToSharedFd, op::AsyncifyFd}; + let op = + AsyncifyFd::new(to_file.to_shared_fd(), move |file: &std::fs::File| { + BufResult(file.set_times(times).map(|_| 0), ()) + }); + match compio::runtime::submit(op).await.0.map(|_| ()) { + Ok(()) => { + log::info!("set times for {} to {:?}", self.to.display(), times); + } + Err(err) => { + log::warn!("failed to set times for {}: {}", self.to.display(), err); + } + } + } + to_file.sync_all().await?; } OpKind::Move { cross_device_copy } => {