From 9a6a187db8ae4ccc7f00d28f5600e99c7ab5c3cc Mon Sep 17 00:00:00 2001 From: mhead Date: Wed, 9 Oct 2024 13:07:05 +0530 Subject: [PATCH] temp commit --- src/uu/mv/src/mv.rs | 15 ++++++++------- tests/by-util/test_mv.rs | 12 ++++++++---- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/uu/mv/src/mv.rs b/src/uu/mv/src/mv.rs index fce054d2bf..d7e1cf4963 100644 --- a/src/uu/mv/src/mv.rs +++ b/src/uu/mv/src/mv.rs @@ -1016,10 +1016,6 @@ fn copy_metadata(src: &Path, dest: &Path, src_metadata: &fs::Metadata) -> io::Re let permissions = src_metadata.permissions(); fs::set_permissions(dest, permissions)?; - // Copy xattrs - #[cfg(all(unix, not(any(target_os = "macos", target_os = "redox"))))] - fsxattr::copy_xattrs(src, dest)?; - // Copy ownership (if on Unix-like system) #[cfg(unix)] { @@ -1036,18 +1032,23 @@ fn copy_metadata(src: &Path, dest: &Path, src_metadata: &fs::Metadata) -> io::Re level: VerbosityLevel::Silent, }, ) - .map_err(|err| io::Error::new(io::ErrorKind::Other, err))?; + .ok(); } // Copy the modified and accessed timestamps let modified_time = src_metadata.modified()?; let accessed_time = src_metadata.accessed()?; if dest_metadata.is_symlink() { - set_symlink_file_times(dest, accessed_time.into(), modified_time.into())?; + set_symlink_file_times(dest, accessed_time.into(), modified_time.into()).ok(); } else { - set_file_times(dest, accessed_time.into(), modified_time.into())?; + set_file_times(dest, accessed_time.into(), modified_time.into()).ok(); } + // Copy xattrs. + #[cfg(all(unix, not(any(target_os = "macos", target_os = "redox"))))] + fsxattr::copy_xattrs(src, dest) + .map_err(|err| show_error!("{err}")) + .ok(); Ok(()) } diff --git a/tests/by-util/test_mv.rs b/tests/by-util/test_mv.rs index 78871c31a0..583da8f4a0 100644 --- a/tests/by-util/test_mv.rs +++ b/tests/by-util/test_mv.rs @@ -1634,7 +1634,6 @@ mod inter_partition_copying { use tempfile::TempDir; use uucore::display::Quotable; use uucore::fsxattr::retrieve_xattrs; - use xattr::FileExt; // Ensure that the copying code used in an inter-partition move preserve dir structure. #[test] fn test_inter_partition_copying_folder() { @@ -1931,8 +1930,10 @@ mod inter_partition_copying { // Set xattrs for the source file let test_attr = "user.test_attr"; let test_value = b"test value"; - file.set_xattr(test_attr, test_value) + xattr::set(at.plus("dir/file"), test_attr, test_value) .expect("couldn't set xattr for src file"); + let retrieved_xattrs = retrieve_xattrs(at.plus_as_string("dir/file")).unwrap(); + assert!(retrieved_xattrs.contains_key(OsString::from(test_attr).as_os_str())); // Get file times for the source file let src_metadata = file @@ -1952,12 +1953,15 @@ mod inter_partition_copying { // would have a same timestamp is by copying the timestamp of src file. sleep(Duration::from_secs(1)); // mv to other partition - scene + let err = scene .ucmd() .arg("-v") .arg("dir") .arg(other_fs_tempdir.path().to_str().unwrap()) - .succeeds(); + .succeeds() + .stderr_move_str(); + + print!("{err}"); let dest_metadata = other_fs_tempdir .path()