diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index 85f49000f81..1b437c8f4d6 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -739,7 +739,7 @@ fn is_empty_dir(path: &Path) -> bool { fn move_dir(from: &Path, to: &Path, progress_bar: Option<&ProgressBar>) -> FsXResult { // The return value that represents the number of bytes copied. let mut result: u64 = 0; - let mut error_occured = false; + let mut error_occurred = false; for dir_entry_result in WalkDir::new(from) { match dir_entry_result { Ok(dir_entry) => { @@ -759,11 +759,11 @@ fn move_dir(from: &Path, to: &Path, progress_bar: Option<&ProgressBar>) -> FsXRe } } Err(_) => { - error_occured = true; + error_occurred = true; } } } - if !error_occured { + if !error_occurred { remove(from)?; } Ok(result) @@ -797,24 +797,20 @@ fn copy_file( } else { None }; - let result_file_copy = { - let md = from.metadata()?; - if cfg!(unix) && FileTypeExt::is_fifo(&md.file_type()) { - let file_size = md.len(); - uucore::fs::copy_fifo(to)?; - if let Some(progress_bar) = progress_bar { - progress_bar.set_position(file_size + progress_bar_start_val); - } - Ok(file_size) - } else { - if let Some(progress_handler) = progress_handler { - file::copy_with_progress(from, to, ©_options, progress_handler) - } else { - file::copy(from, to, ©_options) - } + + let md = from.metadata()?; + if cfg!(unix) && FileTypeExt::is_fifo(&md.file_type()) { + let file_size = md.len(); + uucore::fs::copy_fifo(to)?; + if let Some(progress_bar) = progress_bar { + progress_bar.set_position(file_size + progress_bar_start_val); } - }; - result_file_copy + Ok(file_size) + } else if let Some(progress_handler) = progress_handler { + file::copy_with_progress(from, to, ©_options, progress_handler) + } else { + file::copy(from, to, ©_options) + } } #[cfg(test)] diff --git a/tests/by-util/test_mv.rs b/tests/by-util/test_mv.rs index db13ff3a44b..979b3327f3d 100644 --- a/tests/by-util/test_mv.rs +++ b/tests/by-util/test_mv.rs @@ -1321,33 +1321,6 @@ fn test_mv_verbose() { "renamed '{file_a}' -> '{file_b}' (backup: '{file_b}~')\n" )); } -#[test] -fn test_verbose_src_symlink() { - let scene = TestScenario::new(util_name!()); - let at = &scene.fixtures; - let file_a = "test_mv_verbose_file_a"; - let ln = "link"; - at.touch(file_a); - at.symlink_file(&file_a, &ln); - scene - .ucmd() - .arg("-v") - .arg(file_a) - .arg(ln) - .succeeds() - .stdout_only(format!("renamed '{file_a}' -> '{ln}'\n")); - - at.touch(file_a); - scene - .ucmd() - .arg("-vb") - .arg(file_a) - .arg(ln) - .succeeds() - .stdout_only(format!( - "renamed '{file_a}' -> '{ln}' (backup: '{ln}~')\n" - )); -} #[test] #[cfg(any(target_os = "linux", target_os = "android"))] // mkdir does not support -m on windows. Freebsd doesn't return a permission error either.