mirror of
https://github.com/nushell/nushell.git
synced 2025-01-25 15:51:28 +01:00
Reduce some repetitive code in files.rs (#1692)
This commit is contained in:
parent
1dab82ffa1
commit
ef3049f5a1
@ -63,29 +63,24 @@ pub(crate) fn dir_entry_dict(
|
|||||||
dict.insert_untagged("type", UntaggedValue::nothing());
|
dict.insert_untagged("type", UntaggedValue::nothing());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut symlink_target_untagged_value: UntaggedValue = UntaggedValue::nothing();
|
||||||
|
|
||||||
if full || with_symlink_targets {
|
if full || with_symlink_targets {
|
||||||
if let Some(md) = metadata {
|
if let Some(md) = metadata {
|
||||||
let ft = md.file_type();
|
if md.file_type().is_symlink() {
|
||||||
if ft.is_symlink() {
|
|
||||||
if let Ok(path_to_link) = filename.read_link() {
|
if let Ok(path_to_link) = filename.read_link() {
|
||||||
dict.insert_untagged(
|
symlink_target_untagged_value =
|
||||||
"target",
|
UntaggedValue::string(path_to_link.to_string_lossy());
|
||||||
UntaggedValue::string(path_to_link.to_string_lossy()),
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
dict.insert_untagged(
|
symlink_target_untagged_value =
|
||||||
"target",
|
UntaggedValue::string("Could not obtain target file's path");
|
||||||
UntaggedValue::string("Could not obtain target file's path"),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
dict.insert_untagged("target", UntaggedValue::nothing());
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
dict.insert_untagged("target", UntaggedValue::nothing());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dict.insert_untagged("target", symlink_target_untagged_value);
|
||||||
|
|
||||||
if full {
|
if full {
|
||||||
if let Some(md) = metadata {
|
if let Some(md) = metadata {
|
||||||
dict.insert_untagged(
|
dict.insert_untagged(
|
||||||
|
Loading…
Reference in New Issue
Block a user