forked from extern/nushell
Show symlink sizes in ls (#1680)
* Show symlink sizes in ls * Reduce redundancy in the size code of ls
This commit is contained in:
parent
c704157bc8
commit
8d197e1b2f
@ -127,16 +127,20 @@ pub(crate) fn dir_entry_dict(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut size_untagged_value: UntaggedValue = UntaggedValue::nothing();
|
||||||
|
|
||||||
if let Some(md) = metadata {
|
if let Some(md) = metadata {
|
||||||
if md.is_file() {
|
if md.is_file() {
|
||||||
dict.insert_untagged("size", UntaggedValue::bytes(md.len() as u64));
|
size_untagged_value = UntaggedValue::bytes(md.len() as u64);
|
||||||
} else {
|
} else if md.file_type().is_symlink() {
|
||||||
dict.insert_untagged("size", UntaggedValue::nothing());
|
if let Ok(symlink_md) = filename.symlink_metadata() {
|
||||||
|
size_untagged_value = UntaggedValue::bytes(symlink_md.len() as u64);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
dict.insert_untagged("size", UntaggedValue::nothing());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dict.insert_untagged("size", size_untagged_value);
|
||||||
|
|
||||||
if let Some(md) = metadata {
|
if let Some(md) = metadata {
|
||||||
if full {
|
if full {
|
||||||
if let Ok(c) = md.created() {
|
if let Ok(c) = md.created() {
|
||||||
|
Loading…
Reference in New Issue
Block a user