Skip to content

Commit

Permalink
Support --preserve flag on filesystems that don't support nanosecond …
Browse files Browse the repository at this point in the history
…precision
  • Loading branch information
wykurz committed Dec 3, 2023
1 parent b120e05 commit f4a330d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions common/src/copy.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use anyhow::{Context, Result};
use async_recursion::async_recursion;
use nix::sys::time::TimeValLike;
use std::os::unix::fs::MetadataExt;
use std::os::unix::prelude::PermissionsExt;

Expand All @@ -19,8 +18,8 @@ async fn set_owner_and_time(dst: &std::path::Path, metadata: &std::fs::Metadata)
let metadata = metadata.to_owned();
tokio::task::spawn_blocking(move || -> Result<()> {
// set timestamps first - those are unlikely to fail
let atime = nix::sys::time::TimeSpec::nanoseconds(metadata.atime_nsec());
let mtime = nix::sys::time::TimeSpec::nanoseconds(metadata.mtime_nsec());
let atime = nix::sys::time::TimeSpec::new(metadata.atime(), metadata.atime_nsec());
let mtime = nix::sys::time::TimeSpec::new(metadata.mtime(), metadata.mtime_nsec());
nix::sys::stat::utimensat(
None,
&dst,
Expand Down

0 comments on commit f4a330d

Please sign in to comment.