Skip to content

Commit

Permalink
temp commit
Browse files Browse the repository at this point in the history
  • Loading branch information
matrixhead committed Oct 9, 2024
1 parent ef3a5eb commit 9a6a187
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
15 changes: 8 additions & 7 deletions src/uu/mv/src/mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
{
Expand All @@ -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();

Check warning on line 1042 in src/uu/mv/src/mv.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/mv/src/mv.rs#L1042

Added line #L1042 was not covered by tests
} 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}"))

Check warning on line 1050 in src/uu/mv/src/mv.rs

View check run for this annotation

Codecov / codecov/patch

src/uu/mv/src/mv.rs#L1050

Added line #L1050 was not covered by tests
.ok();
Ok(())
}

Expand Down
12 changes: 8 additions & 4 deletions tests/by-util/test_mv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand All @@ -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()
Expand Down

0 comments on commit 9a6a187

Please sign in to comment.