|
@@ -5,13 +5,13 @@ use mlua::UserData;
|
|
pub struct PluginNetwork;
|
|
pub struct PluginNetwork;
|
|
impl UserData for PluginNetwork {
|
|
impl UserData for PluginNetwork {
|
|
fn add_methods<'lua, M: mlua::UserDataMethods<'lua, Self>>(methods: &mut M) {
|
|
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 url = args.0;
|
|
let path = args.1;
|
|
let path = args.1;
|
|
|
|
|
|
- let resp = reqwest::get(url).await;
|
|
|
|
|
|
+ let resp = reqwest::blocking::get(url);
|
|
if let Ok(resp) = resp {
|
|
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));
|
|
let file = std::fs::File::create(PathBuf::from(path));
|
|
if file.is_err() {
|
|
if file.is_err() {
|
|
return Ok(false);
|
|
return Ok(false);
|