summaryrefslogtreecommitdiffstats
path: root/src/launcher/download.rs
diff options
context:
space:
mode:
authorLibravatar bigfoot547 <[email protected]>2025-01-13 03:05:17 -0600
committerLibravatar bigfoot547 <[email protected]>2025-01-13 03:05:17 -0600
commit6d0fb7c0f2fc9bf144b50b6bb00328b3f7057832 (patch)
tree38d2840748e5593522542a8fb1c48776afa855fa /src/launcher/download.rs
parentadd some logging and stuff (diff)
more stuff
Diffstat (limited to 'src/launcher/download.rs')
-rw-r--r--src/launcher/download.rs15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/launcher/download.rs b/src/launcher/download.rs
index 8c24cae..ec89a15 100644
--- a/src/launcher/download.rs
+++ b/src/launcher/download.rs
@@ -8,7 +8,7 @@ use reqwest::{Client, IntoUrl, Method, RequestBuilder};
use sha1_smol::{Digest, Sha1};
use tokio::fs;
use tokio::fs::File;
-use tokio::io::{AsyncReadExt, AsyncWriteExt};
+use tokio::io::{self, AsyncReadExt, AsyncWriteExt};
use crate::launcher::constants::USER_AGENT;
pub trait Download: Debug + Display {
@@ -182,13 +182,14 @@ impl Display for VerifiedDownload {
}
impl VerifiedDownload {
- pub fn new(url: &str, path: &Path) -> VerifiedDownload {
+ pub fn new(url: &str, path: &Path, expect_size: Option<usize>, expect_sha1: Option<Digest>) -> VerifiedDownload {
VerifiedDownload {
url: url.to_owned(),
path: path.to_owned(),
- expect_size: None,
- expect_sha1: None,
+ expect_size,
+ expect_sha1,
+
file: None,
sha1: Sha1::new(),
tally: 0
@@ -205,7 +206,11 @@ impl VerifiedDownload {
self
}
- async fn open_output(&mut self) -> Result<(), tokio::io::Error> {
+ pub async fn make_dirs(&self) -> Result<(), io::Error> {
+ fs::create_dir_all(self.path.parent().expect("download created with no containing directory (?)")).await
+ }
+
+ async fn open_output(&mut self) -> Result<(), io::Error> {
self.file.replace(File::create(&self.path).await?);
Ok(())
}