Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins: Load /usr/lib/reset by default #6

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/utils/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ pub static mut CONFIG_STRING: Lazy<String> = Lazy::new(|| {
String::from("")
}
});
#[allow(clippy::declare_interior_mutable_const)]
pub const CONFIG: Lazy<Table> = Lazy::new(parse_config);
pub static CONFIG: Lazy<Table> = Lazy::new(parse_config);

pub fn parse_config() -> Table {
unsafe {
Expand Down
15 changes: 11 additions & 4 deletions src/utils/plugin_setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ static SETUP_LIBS: fn() = || {
}
LIBS_LOADING.store(true, std::sync::atomic::Ordering::SeqCst);
let read_dir: fn(PathBuf) = |dir: PathBuf| {
let binding = CONFIG;
let plugins = binding.get("plugins");
let plugins = CONFIG.get("plugins");
if plugins.is_none() {
LOG!("No plugins entry found in config");
return;
Expand All @@ -69,7 +68,13 @@ static SETUP_LIBS: fn() = || {
return;
}
let plugins = plugins.unwrap();
let plugin_dir = dir.read_dir().expect("Could not read directory");
let plugin_dir = dir.read_dir();
if plugin_dir.is_err() {
// do not print error to ignore the usr/lib if not needed
dbg!("lib not exist brudi");
return;
}
let plugin_dir = plugin_dir.unwrap();
plugin_dir.for_each(|plugin| {
if let Ok(file) = plugin {
if !plugins.contains(&Value::String(String::from(
Expand Down Expand Up @@ -114,8 +119,10 @@ static SETUP_LIBS: fn() = || {
unsafe {
if PLUGIN_DIR.is_dir() {
read_dir(PLUGIN_DIR.clone());
read_dir(PathBuf::from("/usr/lib/reset/"));
} else if let Some(plugin_dir) = plugin_dir {
read_dir(plugin_dir)
read_dir(plugin_dir);
read_dir(PathBuf::from("/usr/lib/reset/"));
}
}
LIBS_LOADED.store(true, std::sync::atomic::Ordering::SeqCst);
Expand Down
Loading