diff options
Diffstat (limited to 'src/launcher/jre')
| -rw-r--r-- | src/launcher/jre/download.rs | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/src/launcher/jre/download.rs b/src/launcher/jre/download.rs index d8631aa..c24b82f 100644 --- a/src/launcher/jre/download.rs +++ b/src/launcher/jre/download.rs @@ -6,7 +6,7 @@ use std::ops::AddAssign; use std::path::{Path, PathBuf}; use log::debug; use lzma_rs::decompress; -use reqwest::{IntoUrl, RequestBuilder}; +use reqwest::{Client, IntoUrl, RequestBuilder}; use sha1_smol::{Digest, Sha1}; use tokio::fs; use tokio::io::AsyncWriteExt; @@ -31,9 +31,6 @@ pub struct LzmaDownloadJob { raw_size: Option<usize>, raw_sha1: Option<Digest>, - com_size: Option<usize>, - com_sha1: Option<Digest>, - raw_sha1_st: Sha1, raw_tally: usize, @@ -52,9 +49,6 @@ impl LzmaDownloadJob { raw_size: raw.size, raw_sha1: raw.sha1, - com_size: lzma.size, - com_sha1: lzma.sha1, - raw_sha1_st: Sha1::new(), raw_tally: 0, @@ -73,9 +67,6 @@ impl LzmaDownloadJob { raw_size: raw.size, raw_sha1: raw.sha1, - com_size: None, - com_sha1: None, - raw_sha1_st: Sha1::new(), raw_tally: 0, @@ -125,11 +116,7 @@ impl Display for LzmaDownloadJob { } impl Download for LzmaDownloadJob { - fn get_url(&self) -> impl IntoUrl { - self.url.as_str() - } - - async fn prepare(&mut self, req: RequestBuilder) -> Result<Option<RequestBuilder>, Box<dyn Error>> { + async fn prepare(&mut self, client: &Client) -> Result<Option<RequestBuilder>, Box<dyn Error>> { if !util::should_download(&self.path, self.raw_size, self.raw_sha1).await? { return Ok(None) } @@ -147,7 +134,7 @@ impl Download for LzmaDownloadJob { let file = options.create(true).write(true).truncate(true).open(&self.path).await?; self.out_file = Some(file); - Ok(Some(req)) + Ok(Some(client.get(&self.url))) } async fn handle_chunk(&mut self, chunk: &[u8]) -> Result<(), Box<dyn Error>> { |
