don't set permissions if they're already the same

master
rascul 5 years ago
parent ddfd04872b
commit 5fbef7333b

@ -38,8 +38,6 @@ fn copy_dir(src: &PathBuf, dst: &PathBuf, verbose: bool) -> MkrootResult<()> {
copy_file(&entry_path, &new_dst)?; copy_file(&entry_path, &new_dst)?;
} }
} else if entry_path.is_dir() { } else if entry_path.is_dir() {
let perms = get_perms(&entry_path)?;
if !new_dst.exists() { if !new_dst.exists() {
if verbose { if verbose {
println!("Creating directory {}", &new_dst.display()); println!("Creating directory {}", &new_dst.display());
@ -53,14 +51,20 @@ fn copy_dir(src: &PathBuf, dst: &PathBuf, verbose: bool) -> MkrootResult<()> {
))); )));
} }
let entry_perms = get_perms(&entry_path)?;
let dst_perms = get_perms(&new_dst)?;
if entry_perms != dst_perms {
if verbose { if verbose {
println!( println!(
"Setting permissions {:o} on {}", "Setting permissions {:o} on {}",
&perms.mode(), &entry_perms.mode(),
&new_dst.display() &new_dst.display()
); );
} }
set_perms(&new_dst, perms)?;
set_perms(&new_dst, entry_perms)?;
}
copy_dir(&entry_path, &new_dst, verbose)?; copy_dir(&entry_path, &new_dst, verbose)?;
} }

Loading…
Cancel
Save