mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
mv: moving dangling symlinks into directories (#8064)
* Fix linting and style issues * Change condition to not fail for dangling symlinks The function `move_files_into_dir` had a condition that failed when a dangling symlink was moved into a folder, which resulted in a file or directory doesn't exist error * Added a test case
This commit is contained in:
parent
c332d96203
commit
a7a493a604
2 changed files with 14 additions and 1 deletions
|
@ -526,7 +526,7 @@ fn move_files_into_dir(files: &[PathBuf], target_dir: &Path, options: &Options)
|
|||
};
|
||||
|
||||
for sourcepath in files {
|
||||
if !sourcepath.exists() {
|
||||
if sourcepath.symlink_metadata().is_err() {
|
||||
show!(MvError::NoSuchFile(sourcepath.quote().to_string()));
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -443,6 +443,19 @@ fn test_mv_same_hardlink() {
|
|||
.stderr_is(format!("mv: '{file_a}' and '{file_b}' are the same file\n"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(unix, not(target_os = "android")))]
|
||||
fn test_mv_dangling_symlink_to_folder() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.symlink_file("404", "abc");
|
||||
at.mkdir("x");
|
||||
|
||||
ucmd.arg("abc").arg("x").succeeds();
|
||||
|
||||
assert!(at.symlink_exists("x/abc"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(all(unix, not(target_os = "android")))]
|
||||
fn test_mv_same_symlink() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue