From 81ff598d6cbf476be8525d56833e3e660d8c1c98 Mon Sep 17 00:00:00 2001 From: "Joseph T. Lyons" Date: Sun, 3 May 2020 22:58:11 -0400 Subject: [PATCH] Fix column bugs associated with previous refactoring (#1705) * Fix: the symlink target column will only dispaly if either the `full` or `with_symlink_targets` options are given * If the metadata for every item in the size column is None, do not show the size column * Do not show the symlink target column if the metadata is None for all the items in the table --- crates/nu-cli/src/data/files.rs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/crates/nu-cli/src/data/files.rs b/crates/nu-cli/src/data/files.rs index 72971c7fd0..7351f96736 100644 --- a/crates/nu-cli/src/data/files.rs +++ b/crates/nu-cli/src/data/files.rs @@ -65,10 +65,10 @@ pub(crate) fn dir_entry_dict( dict.insert_untagged("type", UntaggedValue::nothing()); } - let mut symlink_target_untagged_value: UntaggedValue = UntaggedValue::nothing(); - if full || with_symlink_targets { if let Some(md) = metadata { + let mut symlink_target_untagged_value: UntaggedValue = UntaggedValue::nothing(); + if md.file_type().is_symlink() { if let Ok(path_to_link) = filename.read_link() { symlink_target_untagged_value = @@ -78,11 +78,11 @@ pub(crate) fn dir_entry_dict( UntaggedValue::string("Could not obtain target file's path"); } } + + dict.insert_untagged("target", symlink_target_untagged_value); } } - dict.insert_untagged("target", symlink_target_untagged_value); - if full { if let Some(md) = metadata { dict.insert_untagged( @@ -124,9 +124,9 @@ pub(crate) fn dir_entry_dict( } } - let mut size_untagged_value: UntaggedValue = UntaggedValue::nothing(); - if let Some(md) = metadata { + let mut size_untagged_value: UntaggedValue = UntaggedValue::nothing(); + if md.is_dir() { let dir_size: u64 = if du { let params = DirBuilder::new( @@ -153,9 +153,9 @@ pub(crate) fn dir_entry_dict( size_untagged_value = UntaggedValue::bytes(symlink_md.len() as u64); } } - } - dict.insert_untagged("size", size_untagged_value); + dict.insert_untagged("size", size_untagged_value); + } if let Some(md) = metadata { if full {