Skip to content

Commit 673a159

Browse files
committed
added handling for none value for file user name and file group name
1 parent 3814ccb commit 673a159

1 file changed

Lines changed: 8 additions & 10 deletions

File tree

src/main.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,10 @@ pub fn show_group_name(e: &std::path::PathBuf) -> Result<(), Box<dyn std::error:
238238
print!(
239239
"{} ",
240240
Style::new().bold().paint(
241-
get_group_by_gid(fs::symlink_metadata(e)?.gid())
242-
.unwrap()
243-
.name()
244-
.to_str()
245-
.unwrap()
241+
match get_group_by_gid(fs::symlink_metadata(e)?.gid()).as_ref() {
242+
Some(n) => n.name().to_str().unwrap(),
243+
None => ""
244+
}
246245
)
247246
);
248247
Ok(())
@@ -255,11 +254,10 @@ pub fn show_user_name(e: &std::path::PathBuf) -> Result<(), Box<dyn std::error::
255254
print!(
256255
"{} ",
257256
Style::new().bold().paint(
258-
get_user_by_uid(fs::symlink_metadata(e)?.uid())
259-
.unwrap()
260-
.name()
261-
.to_str()
262-
.unwrap()
257+
match get_user_by_uid(fs::symlink_metadata(e)?.uid()).as_ref() {
258+
Some(n) => n.name().to_str().unwrap(),
259+
None => ""
260+
}
263261
)
264262
);
265263
Ok(())

0 commit comments

Comments
 (0)