Removed loader
This commit is contained in:
@@ -7,7 +7,6 @@ edition = "2024"
|
||||
anyhow = "1.0.99"
|
||||
base64 = "0.22.1"
|
||||
chrono = "0.4.42"
|
||||
libloading = { version = "0.8.8", optional = true }
|
||||
once_cell = "1.21.3"
|
||||
rand = "0.9.2"
|
||||
rusqlite = "0.37.0"
|
||||
@@ -18,4 +17,3 @@ ureq = "3.1.2"
|
||||
|
||||
[features]
|
||||
default = []
|
||||
loader = ["libloading"]
|
||||
|
||||
@@ -63,11 +63,6 @@ impl Server {
|
||||
|
||||
pub fn run(self: &Arc<Self>) -> crate::Result<()> {
|
||||
// Load plugins
|
||||
#[cfg(feature = "loader")]
|
||||
utils::loader::load_plugins(
|
||||
&mut *self.plugins.lock().unwrap(),
|
||||
&self.root.join("./plugins"),
|
||||
)?;
|
||||
|
||||
// Initialize plugins
|
||||
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
use std::path::Path;
|
||||
|
||||
use libloading::{Library, Symbol};
|
||||
|
||||
use crate::{logger, utils::plugin::DynPlugin, utils::vfs};
|
||||
|
||||
logger! {
|
||||
const LOGGER "Loader"
|
||||
}
|
||||
|
||||
pub fn load_plugin(path: &Path) -> anyhow::Result<DynPlugin> {
|
||||
unsafe {
|
||||
LOGGER.info(format!("Loading plugin: {:?}", path));
|
||||
let lib = Library::new(path)?;
|
||||
let func: Symbol<extern "C" fn() -> DynPlugin> = lib.get(b"load_plugin").unwrap();
|
||||
Ok(func())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_plugins(arr: &mut Vec<DynPlugin>, path: &Path) -> crate::Result<()> {
|
||||
LOGGER.info("Loading plugins");
|
||||
vfs::dir(path)?;
|
||||
if path.is_dir() {
|
||||
for entry in std::fs::read_dir(path)? {
|
||||
let entry = entry?;
|
||||
let path = entry.path();
|
||||
if path.extension().and_then(|s| s.to_str()) == Some("dylib") {
|
||||
match load_plugin(&path) {
|
||||
Ok(plugin) => {
|
||||
arr.push(plugin);
|
||||
}
|
||||
Err(e) => LOGGER.error(format!("Failed to load plugin {:?}: {}", path, e)),
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LOGGER.error(format!("{:?} is not a directory", path));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
pub mod auth;
|
||||
pub mod client;
|
||||
pub mod database;
|
||||
#[cfg(feature = "loader")]
|
||||
pub mod loader;
|
||||
pub mod logger;
|
||||
pub mod vfs;
|
||||
|
||||
Reference in New Issue
Block a user