From 5fbef7333b5f007758101c4613da872fff8e6442 Mon Sep 17 00:00:00 2001 From: rascul Date: Mon, 26 Aug 2019 17:42:22 -0500 Subject: [PATCH] don't set permissions if they're already the same --- src/skel.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/skel.rs b/src/skel.rs index 3e3b88b..97376af 100644 --- a/src/skel.rs +++ b/src/skel.rs @@ -38,8 +38,6 @@ fn copy_dir(src: &PathBuf, dst: &PathBuf, verbose: bool) -> MkrootResult<()> { copy_file(&entry_path, &new_dst)?; } } else if entry_path.is_dir() { - let perms = get_perms(&entry_path)?; - if !new_dst.exists() { if verbose { println!("Creating directory {}", &new_dst.display()); @@ -53,14 +51,20 @@ fn copy_dir(src: &PathBuf, dst: &PathBuf, verbose: bool) -> MkrootResult<()> { ))); } - if verbose { - println!( - "Setting permissions {:o} on {}", - &perms.mode(), - &new_dst.display() - ); + let entry_perms = get_perms(&entry_path)?; + let dst_perms = get_perms(&new_dst)?; + + if entry_perms != dst_perms { + if verbose { + println!( + "Setting permissions {:o} on {}", + &entry_perms.mode(), + &new_dst.display() + ); + } + + set_perms(&new_dst, entry_perms)?; } - set_perms(&new_dst, perms)?; copy_dir(&entry_path, &new_dst, verbose)?; }