mirror of
https://github.com/nushell/nushell.git
synced 2024-12-25 00:19:39 +01:00
Fixed mv not moving files on Windows. (#1342)
Move files correctly in windows.
This commit is contained in:
parent
44a114111e
commit
ed86b1fbe8
@ -720,6 +720,22 @@ impl Shell for FilesystemShell {
|
|||||||
}
|
}
|
||||||
Ok(o) => o,
|
Ok(o) => o,
|
||||||
}
|
}
|
||||||
|
} else if src.is_file() {
|
||||||
|
match std::fs::copy(src, dst) {
|
||||||
|
Err(e) => {
|
||||||
|
return Err(ShellError::labeled_error(
|
||||||
|
format!(
|
||||||
|
"Moving file {:?} to {:?} aborted. {:}",
|
||||||
|
src,
|
||||||
|
dst,
|
||||||
|
e.to_string(),
|
||||||
|
),
|
||||||
|
e.to_string(),
|
||||||
|
name_tag,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
Ok(_o) => (),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,6 +96,7 @@ fn moves_the_directory_inside_directory_if_path_to_move_is_existing_directory()
|
|||||||
|
|
||||||
assert!(!original_dir.exists());
|
assert!(!original_dir.exists());
|
||||||
assert!(expected.exists());
|
assert!(expected.exists());
|
||||||
|
assert!(files_exist_at(vec!["jonathan.txt"], expected))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,3 +181,40 @@ fn moves_using_a_glob() {
|
|||||||
));
|
));
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn moves_a_directory_with_files() {
|
||||||
|
Playground::setup("mv_test_9", |dirs, sandbox| {
|
||||||
|
sandbox
|
||||||
|
.mkdir("vehicles/car")
|
||||||
|
.mkdir("vehicles/bicycle")
|
||||||
|
.with_files(vec![
|
||||||
|
EmptyFile("vehicles/car/car1.txt"),
|
||||||
|
EmptyFile("vehicles/car/car2.txt"),
|
||||||
|
])
|
||||||
|
.with_files(vec![
|
||||||
|
EmptyFile("vehicles/bicycle/bicycle1.txt"),
|
||||||
|
EmptyFile("vehicles/bicycle/bicycle2.txt"),
|
||||||
|
]);
|
||||||
|
|
||||||
|
let original_dir = dirs.test().join("vehicles");
|
||||||
|
let expected_dir = dirs.test().join("expected");
|
||||||
|
|
||||||
|
nu!(
|
||||||
|
cwd: dirs.test(),
|
||||||
|
"mv vehicles expected"
|
||||||
|
);
|
||||||
|
|
||||||
|
assert!(!original_dir.exists());
|
||||||
|
assert!(expected_dir.exists());
|
||||||
|
assert!(files_exist_at(
|
||||||
|
vec![
|
||||||
|
"car/car1.txt",
|
||||||
|
"car/car2.txt",
|
||||||
|
"bicycle/bicycle1.txt",
|
||||||
|
"bicycle/bicycle2.txt"
|
||||||
|
],
|
||||||
|
expected_dir
|
||||||
|
));
|
||||||
|
})
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user