Fix Windows again

This commit is contained in:
sxyazi 2024-01-03 01:24:33 +08:00
parent 5328747009
commit b13a2a19ff
No known key found for this signature in database

View file

@ -1,14 +1,16 @@
use mlua::{Lua, Table}; use mlua::{Lua, Table};
use uzers::{Groups, Users, UsersCache};
use yazi_shared::RoCell; use yazi_shared::RoCell;
use super::Utils; use super::Utils;
static CACHE: RoCell<UsersCache> = RoCell::new();
impl Utils { impl Utils {
#[cfg(unix)] #[cfg(unix)]
pub(super) fn user(lua: &Lua, ya: &Table) -> mlua::Result<()> { pub(super) fn user(lua: &Lua, ya: &Table) -> mlua::Result<()> {
#[cfg(unix)]
use uzers::{Groups, Users, UsersCache};
#[cfg(unix)]
static CACHE: RoCell<UsersCache> = RoCell::new();
CACHE.with(Default::default); CACHE.with(Default::default);
ya.set("uid", lua.create_function(|_, ()| Ok(CACHE.get_current_uid()))?)?; ya.set("uid", lua.create_function(|_, ()| Ok(CACHE.get_current_uid()))?)?;