diff --git a/src/lib.rs b/src/lib.rs index 94ec9cd..0d8dd4f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -468,10 +468,10 @@ impl Config { // exist for now. let lib_dst = dst.with_file_name(format!("{}.lib", lib_name)); let _ = fs::remove_file(&lib_dst); - if fs::hard_link(&dst, &lib_dst).is_err() { - println!("Hard-linking from {:?} to {:?} failed. Trying to copy...", dst, lib_dst); - fs::copy(&dst, &lib_dst).expect("Copying from {:?} to {:?} FAILED."); - }; + fs::hard_link(&dst, &lib_dst).or_else(|_| { + //if hard-link fails, just copy (ignoring the number of bytes written) + fs::copy(&dst, &lib_dst).map(|_| ()) + }).expect("Copying from {:?} to {:?} failed.");; } else { let ar = self.get_ar(); let cmd = ar.file_name().unwrap().to_string_lossy();