From ddde9204c72dd867f920f07f6483be03dda7cf68 Mon Sep 17 00:00:00 2001 From: fxqnlr Date: Mon, 28 Nov 2022 22:55:14 +0100 Subject: basically update impl; added "good" download; auto dl on new mod; db to 0.4; etc --- src/lib.rs | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) (limited to 'src/lib.rs') diff --git a/src/lib.rs b/src/lib.rs index e4ebf76..971f544 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,13 +4,12 @@ pub mod commands; pub mod input; pub mod db; pub mod error; +pub mod files; -use std::{io::{Error, ErrorKind, Write}, fs::File}; +use std::io::{Error, ErrorKind}; pub use apis::*; pub use commands::*; -use futures_util::StreamExt; -use reqwest::Client; #[derive(Debug, Clone, PartialEq, Eq)] pub enum Modloader { @@ -34,23 +33,3 @@ impl Modloader { } } } - -pub async fn download_file(url: String, path: String, name: String) -> Result<(), Box> { - println!("Downloading {}", url); - let dl_path_file = format!("{}/{}", path, name); - let res = Client::new() - .get(String::from(&url)) - .send() - .await?; - - // download chunks - let mut file = File::create(String::from(&dl_path_file))?; - let mut stream = res.bytes_stream(); - - while let Some(item) = stream.next().await { - let chunk = item?; - file.write_all(&chunk)?; - } - - Ok(()) -} -- cgit v1.2.3