mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
Merge pull request #1644 from sylvestre/install-copy
Small improvements on "install"
This commit is contained in:
commit
a10346eb23
2 changed files with 6 additions and 7 deletions
|
@ -390,7 +390,9 @@ fn directory(paths: Vec<String>, b: Behavior) -> i32 {
|
||||||
/// Test if the path is a new file path that can be
|
/// Test if the path is a new file path that can be
|
||||||
/// created immediately
|
/// created immediately
|
||||||
fn is_new_file_path(path: &Path) -> bool {
|
fn is_new_file_path(path: &Path) -> bool {
|
||||||
path.is_file() || !path.exists() && path.parent().map(Path::is_dir).unwrap_or(true)
|
!path.exists()
|
||||||
|
&& (path.parent().map(Path::is_dir).unwrap_or(true)
|
||||||
|
|| path.parent().unwrap().to_string_lossy().is_empty()) // In case of a simple file
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Perform an install, given a list of paths and behavior.
|
/// Perform an install, given a list of paths and behavior.
|
||||||
|
@ -409,6 +411,7 @@ fn standard(paths: Vec<String>, b: Behavior) -> i32 {
|
||||||
let target = Path::new(paths.last().unwrap());
|
let target = Path::new(paths.last().unwrap());
|
||||||
|
|
||||||
if (target.is_file() || is_new_file_path(target)) && sources.len() == 1 {
|
if (target.is_file() || is_new_file_path(target)) && sources.len() == 1 {
|
||||||
|
/* If the target already exist or directly creatable */
|
||||||
copy_file_to_file(&sources[0], &target.to_path_buf(), &b)
|
copy_file_to_file(&sources[0], &target.to_path_buf(), &b)
|
||||||
} else {
|
} else {
|
||||||
copy_files_into_dir(sources, &target.to_path_buf(), &b)
|
copy_files_into_dir(sources, &target.to_path_buf(), &b)
|
||||||
|
|
|
@ -224,7 +224,6 @@ fn test_install_target_new_file_failing_nonexistent_parent() {
|
||||||
assert!(err.contains("not a directory"))
|
assert!(err.contains("not a directory"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// These two tests are failing but should work
|
// These two tests are failing but should work
|
||||||
#[test]
|
#[test]
|
||||||
fn test_install_copy_file() {
|
fn test_install_copy_file() {
|
||||||
|
@ -233,13 +232,10 @@ fn test_install_copy_file() {
|
||||||
let file2 = "test_install_target_dir_file_a2";
|
let file2 = "test_install_target_dir_file_a2";
|
||||||
|
|
||||||
at.touch(file1);
|
at.touch(file1);
|
||||||
ucmd.arg(file1).arg(file2).fails();
|
|
||||||
|
|
||||||
/* Uncomment when fixed
|
|
||||||
ucmd.arg(file1).arg(file2).succeeds().no_stderr();
|
ucmd.arg(file1).arg(file2).succeeds().no_stderr();
|
||||||
|
|
||||||
assert!(at.file_exists(file1));
|
assert!(at.file_exists(file1));
|
||||||
assert!(at.file_exists(file2));*/
|
assert!(at.file_exists(file2));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue