From aa8996d79a92dd54c3af545232e74636ff01b389 Mon Sep 17 00:00:00 2001 From: Leo dev Date: Mon, 22 Dec 2025 21:41:30 +0100 Subject: [PATCH] Fixed plugin loader dir not found --- src/plugin/loader.rs | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/src/plugin/loader.rs b/src/plugin/loader.rs index 46508a6..631fe24 100644 --- a/src/plugin/loader.rs +++ b/src/plugin/loader.rs @@ -70,17 +70,24 @@ impl PluginLoader { let plugin_clients = self.plugin_clients.clone(); let listener = TcpListener::bind("0.0.0.0:7243").unwrap(); + let handle_plugin = move |stream: Result| -> crate::Result<()> { + let stream = stream?; + let mut reader = BufReader::new(&stream); + let mut s = String::new(); + reader.read_line(&mut s)?; + let plugin_handshake: PluginHandshake = serde_json::from_str(&s)?; + plugin_clients + .lock() + .unwrap() + .insert(plugin_handshake.id, stream); + Ok(()) + }; + std::thread::spawn(move || { for stream in listener.incoming() { - let stream = stream.unwrap(); - let mut reader = BufReader::new(&stream); - let mut s = String::new(); - reader.read_line(&mut s).unwrap(); - let plugin_handshake: PluginHandshake = serde_json::from_str(&s).unwrap(); - plugin_clients - .lock() - .unwrap() - .insert(plugin_handshake.id, stream); + if let Err(e) = handle_plugin(stream) { + LOGGER.error(format!("Plugin error: {e}")); + } } }); }