plugin_framework, ignore loading uninstalled plugins
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
1747766f73
commit
d985bd5607
@ -97,8 +97,15 @@ pub fn init() {
|
|||||||
log::error!("Failed to remove plugins: {}", e);
|
log::error!("Failed to remove plugins: {}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if let Err(e) = plugins::load_plugins() {
|
match manager::get_uninstall_id_set() {
|
||||||
log::error!("Failed to load plugins: {}", e);
|
Ok(ids) => {
|
||||||
|
if let Err(e) = plugins::load_plugins(&ids) {
|
||||||
|
log::error!("Failed to load plugins: {}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
log::error!("Failed to load plugins: {}", e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ use hbb_common::{
|
|||||||
};
|
};
|
||||||
use serde_derive::Serialize;
|
use serde_derive::Serialize;
|
||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::{HashMap, HashSet},
|
||||||
ffi::{c_char, c_void},
|
ffi::{c_char, c_void},
|
||||||
path::PathBuf,
|
path::PathBuf,
|
||||||
sync::{Arc, RwLock},
|
sync::{Arc, RwLock},
|
||||||
@ -263,7 +263,7 @@ const DYLIB_SUFFIX: &str = ".so";
|
|||||||
#[cfg(target_os = "macos")]
|
#[cfg(target_os = "macos")]
|
||||||
const DYLIB_SUFFIX: &str = ".dylib";
|
const DYLIB_SUFFIX: &str = ".dylib";
|
||||||
|
|
||||||
pub(super) fn load_plugins() -> ResultType<()> {
|
pub(super) fn load_plugins(uninstalled_ids: &HashSet<String>) -> ResultType<()> {
|
||||||
let plugins_dir = super::get_plugins_dir()?;
|
let plugins_dir = super::get_plugins_dir()?;
|
||||||
if !plugins_dir.exists() {
|
if !plugins_dir.exists() {
|
||||||
std::fs::create_dir_all(&plugins_dir)?;
|
std::fs::create_dir_all(&plugins_dir)?;
|
||||||
@ -273,7 +273,16 @@ pub(super) fn load_plugins() -> ResultType<()> {
|
|||||||
Ok(entry) => {
|
Ok(entry) => {
|
||||||
let plugin_dir = entry.path();
|
let plugin_dir = entry.path();
|
||||||
if plugin_dir.is_dir() {
|
if plugin_dir.is_dir() {
|
||||||
load_plugin_dir(&plugin_dir);
|
if let Some(plugin_id) = plugin_dir.file_name().and_then(|f| f.to_str()) {
|
||||||
|
if uninstalled_ids.contains(plugin_id) {
|
||||||
|
log::debug!(
|
||||||
|
"Ignore loading '{}' as it should be uninstalled",
|
||||||
|
plugin_id
|
||||||
|
);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
load_plugin_dir(&plugin_dir);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user