to_string_lossy().to_string() for users/groups

This commit is contained in:
ChristianVisintin 2020-11-29 15:56:01 +01:00
parent badbddb240
commit 1ff42ecf13

View file

@ -151,7 +151,7 @@ impl std::fmt::Display for FsEntry {
// Get username // Get username
let username: String = match dir.user { let username: String = match dir.user {
Some(uid) => match get_user_by_uid(uid) { Some(uid) => match get_user_by_uid(uid) {
Some(user) => user.name(), Some(user) => user.name().to_string_lossy().to_string(),
None => uid.to_string(), None => uid.to_string(),
}, },
None => String::from("0"), None => String::from("0"),
@ -159,7 +159,7 @@ impl std::fmt::Display for FsEntry {
// Get group // Get group
let group: String = match dir.group { let group: String = match dir.group {
Some(gid) => match get_group_by_gid(gid) { Some(gid) => match get_group_by_gid(gid) {
Some(group) => group.name(), Some(group) => group.name().to_string_lossy().to_string(),
None => gid.to_string(), None => gid.to_string(),
}, },
None => String::from("0"), None => String::from("0"),
@ -240,7 +240,7 @@ impl std::fmt::Display for FsEntry {
// Get username // Get username
let username: String = match file.user { let username: String = match file.user {
Some(uid) => match get_user_by_uid(uid) { Some(uid) => match get_user_by_uid(uid) {
Some(user) => user.name(), Some(user) => user.name().to_string_lossy().to_string(),
None => uid.to_string(), None => uid.to_string(),
}, },
None => String::from("0"), None => String::from("0"),
@ -248,7 +248,7 @@ impl std::fmt::Display for FsEntry {
// Get group // Get group
let group: String = match file.group { let group: String = match file.group {
Some(gid) => match get_group_by_gid(gid) { Some(gid) => match get_group_by_gid(gid) {
Some(group) => group.name(), Some(group) => group.name().to_string_lossy().to_string(),
None => gid.to_string(), None => gid.to_string(),
}, },
None => String::from("0"), None => String::from("0"),