diff --git a/Cargo.toml b/Cargo.toml index b18c90a9e..4fe9eeb7f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -46,7 +46,7 @@ walkdir = "2" # tools download dirs = "4.0.0" -reqwest = { version = "0.11", features = ["rustls-tls", "stream", "trust-dns"] } +reqwest = { version = "0.11", features = ["rustls-tls", "stream", "trust-dns", "blocking"] } flate2 = "1.0.22" tar = "0.4.38" zip = "0.6.2" diff --git a/src/plugin/interface/network.rs b/src/plugin/interface/network.rs index af6b6ae12..8d940ddc4 100644 --- a/src/plugin/interface/network.rs +++ b/src/plugin/interface/network.rs @@ -5,13 +5,13 @@ use mlua::UserData; pub struct PluginNetwork; impl UserData for PluginNetwork { fn add_methods<'lua, M: mlua::UserDataMethods<'lua, Self>>(methods: &mut M) { - methods.add_async_function("download_file", |_, args: (String, String)| async move { + methods.add_function("download_file", |_, args: (String, String)| { let url = args.0; let path = args.1; - let resp = reqwest::get(url).await; + let resp = reqwest::blocking::get(url); if let Ok(resp) = resp { - let mut content = Cursor::new(resp.bytes().await.unwrap()); + let mut content = Cursor::new(resp.bytes().unwrap()); let file = std::fs::File::create(PathBuf::from(path)); if file.is_err() { return Ok(false); diff --git a/src/plugin/interface/path.rs b/src/plugin/interface/path.rs index 1dd3997cf..f0d36bd78 100644 --- a/src/plugin/interface/path.rs +++ b/src/plugin/interface/path.rs @@ -1,16 +1,18 @@ use std::path::PathBuf; -use mlua::UserData; +use mlua::{UserData, Variadic}; pub struct PluginPath; impl UserData for PluginPath { fn add_methods<'lua, M: mlua::UserDataMethods<'lua, Self>>(methods: &mut M) { // join function - methods.add_function("join", |_, args: (String, String)| { - let current_path = PathBuf::from(args.0); - let new_path = current_path.join(args.1); - Ok(new_path.to_str().unwrap().to_string()) - }); + methods.add_function("join", |_, args: Variadic| { + let mut path = PathBuf::new(); + for i in args { + path = path.join(i); + } + Ok(path.to_str().unwrap().to_string()) + }); // parent function methods.add_function("parent", |_, path: String| { diff --git a/src/plugin/mod.rs b/src/plugin/mod.rs index c3d7f43ab..c77764fd4 100644 --- a/src/plugin/mod.rs +++ b/src/plugin/mod.rs @@ -298,25 +298,6 @@ impl PluginManager { plugin_path } - pub fn plugin_list_from_dir() -> Vec { - let mut res = vec![]; - - let app_path = app_path(); - let plugin_path = app_path.join("plugins"); - - let child_dirs = std::fs::read_dir(plugin_path).unwrap(); - for p in child_dirs { - if let Ok(p) = p { - if p.path().is_dir() && p.file_name() != "library" { - if p.path().join("init.lua").is_file() { - res.push(p.file_name().to_str().unwrap().to_string()); - } - } - } - } - res - } - pub fn plugin_list() -> Vec { let mut res = vec![];