mirror of
https://github.com/sxyazi/yazi.git
synced 2026-07-25 08:41:05 +00:00
switched to using ya.user_name
This commit is contained in:
parent
0ff7abb7aa
commit
e7d2ec2460
5 changed files with 5 additions and 34 deletions
11
Cargo.lock
generated
11
Cargo.lock
generated
|
|
@ -2272,16 +2272,6 @@ dependencies = [
|
|||
"percent-encoding",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "users"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24cc0f6d6f267b73e5a2cadf007ba8f9bc39c6a6f9666f8cf25ea809a153b032"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"log",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "utf8parse"
|
||||
version = "0.2.1"
|
||||
|
|
@ -2931,7 +2921,6 @@ dependencies = [
|
|||
"serde",
|
||||
"tokio",
|
||||
"tracing",
|
||||
"users",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -22,7 +22,11 @@ function Folder:linemode(area, files)
|
|||
elseif mode == "permissions" then
|
||||
spans[#spans + 1] = ui.Span(f.cha:permissions() or "")
|
||||
elseif mode == "owner" then
|
||||
spans[#spans + 1] = ui.Span(f.cha:owner() or "")
|
||||
local username = ya.user_name(f.cha.uid)
|
||||
local groupname = ya.group_name(f.cha.gid)
|
||||
if username and groupname then
|
||||
spans[#spans + 1] = ui.Span(username .. ":" .. groupname)
|
||||
end
|
||||
end
|
||||
|
||||
spans[#spans + 1] = ui.Span(" ")
|
||||
|
|
|
|||
|
|
@ -44,14 +44,6 @@ impl Cha {
|
|||
None::<String>,
|
||||
)
|
||||
});
|
||||
reg.add_method("owner", |_, me, ()| {
|
||||
Ok(
|
||||
#[cfg(unix)]
|
||||
Some(yazi_shared::fs::owner(me.uid, me.gid)),
|
||||
#[cfg(windows)]
|
||||
None::<String>,
|
||||
)
|
||||
});
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -27,4 +27,3 @@ tracing = { version = "0.1.40", features = [ "max_level_debug", "release_max_lev
|
|||
|
||||
[target."cfg(unix)".dependencies]
|
||||
libc = "0.2.153"
|
||||
users = "0.11.0"
|
||||
|
|
|
|||
|
|
@ -147,19 +147,6 @@ pub fn permissions(m: libc::mode_t) -> String {
|
|||
s
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
pub fn owner(uid: u32, gid: u32) -> String {
|
||||
let username = match users::get_user_by_uid(uid) {
|
||||
Some(u) => u.name().to_str().unwrap_or_default().to_string(),
|
||||
None => String::default(),
|
||||
};
|
||||
let groupname = match users::get_group_by_gid(gid) {
|
||||
Some(g) => g.name().to_str().unwrap_or_default().to_string(),
|
||||
None => String::default(),
|
||||
};
|
||||
format!("{username} {groupname}")
|
||||
}
|
||||
|
||||
// Find the max common root in a list of files
|
||||
// e.g. /a/b/c, /a/b/d -> /a/b
|
||||
// /aa/bb/cc, /aa/dd/ee -> /aa
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue