mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
cp: move symlink check to the right place
This commit is contained in:
parent
12a1c87cb8
commit
315bfd65a3
1 changed files with 6 additions and 8 deletions
|
@ -895,14 +895,7 @@ fn copy_source(
|
||||||
options: &Options,
|
options: &Options,
|
||||||
) -> CopyResult<()> {
|
) -> CopyResult<()> {
|
||||||
let source_path = Path::new(&source);
|
let source_path = Path::new(&source);
|
||||||
// if no-dereference is enabled and this is a symlink, don't treat it as a directory
|
if source_path.is_dir() {
|
||||||
if source_path.is_dir()
|
|
||||||
&& !(!options.dereference
|
|
||||||
&& fs::symlink_metadata(source_path)
|
|
||||||
.unwrap()
|
|
||||||
.file_type()
|
|
||||||
.is_symlink())
|
|
||||||
{
|
|
||||||
// Copy as directory
|
// Copy as directory
|
||||||
copy_directory(source, target, options)
|
copy_directory(source, target, options)
|
||||||
} else {
|
} else {
|
||||||
|
@ -943,6 +936,11 @@ fn copy_directory(root: &Path, target: &TargetSlice, options: &Options) -> CopyR
|
||||||
return Err(format!("omitting directory '{}'", root.display()).into());
|
return Err(format!("omitting directory '{}'", root.display()).into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if no-dereference is enabled and this is a symlink, copy it as a file
|
||||||
|
if !options.dereference && fs::symlink_metadata(root).unwrap().file_type().is_symlink() {
|
||||||
|
return copy_file(root, target, options);
|
||||||
|
}
|
||||||
|
|
||||||
let root_path = env::current_dir().unwrap().join(root);
|
let root_path = env::current_dir().unwrap().join(root);
|
||||||
|
|
||||||
let root_parent = if target.exists() {
|
let root_parent = if target.exists() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue