mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-19 08:23:01 +08:00
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);
|
||||
}
|
||||
}
|
||||
if let Err(e) = plugins::load_plugins() {
|
||||
log::error!("Failed to load plugins: {}", e);
|
||||
match manager::get_uninstall_id_set() {
|
||||
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 std::{
|
||||
collections::HashMap,
|
||||
collections::{HashMap, HashSet},
|
||||
ffi::{c_char, c_void},
|
||||
path::PathBuf,
|
||||
sync::{Arc, RwLock},
|
||||
@ -263,7 +263,7 @@ const DYLIB_SUFFIX: &str = ".so";
|
||||
#[cfg(target_os = "macos")]
|
||||
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()?;
|
||||
if !plugins_dir.exists() {
|
||||
std::fs::create_dir_all(&plugins_dir)?;
|
||||
@ -273,7 +273,16 @@ pub(super) fn load_plugins() -> ResultType<()> {
|
||||
Ok(entry) => {
|
||||
let plugin_dir = entry.path();
|
||||
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) => {
|
||||
|
Loading…
Reference in New Issue
Block a user