diff options
Diffstat (limited to 'src/launcher/version.rs')
| -rw-r--r-- | src/launcher/version.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/launcher/version.rs b/src/launcher/version.rs index 411ac59..40bb953 100644 --- a/src/launcher/version.rs +++ b/src/launcher/version.rs @@ -4,7 +4,7 @@ use std::collections::HashSet; use std::fmt::Display; use std::path::{Path, PathBuf}; -use log::{debug, info, warn}; +use log::{debug, info, trace, warn}; use sha1_smol::Digest; use tokio::{fs, io}; use crate::util; @@ -51,19 +51,22 @@ impl RemoteVersionList { // download it let ver_text = reqwest::get(ver.url.as_str()).await?.error_for_status()?.text().await?; - + debug!("Validating downloaded {}...", ver.id); // make sure it's valid util::verify_sha1(ver.sha1, ver_text.as_str()) .map_err::<Box<dyn Error>, _>(|e| format!("downloaded version {} has wrong hash! (expect {}, got {})", ver.id.as_str(), &ver.sha1, e).as_str().into())?; - + // make sure it's well-formed - let cver: CompleteVersion = serde_json::from_str(ver.url.as_str())?; + let cver: CompleteVersion = serde_json::from_str(ver_text.as_str())?; debug!("Saving version {}...", ver.id); // write it out - tokio::fs::write(path, ver_text).await?; + tokio::fs::write(path, ver_text).await.map_err(|e| { + warn!("Failed to save version {}: {}", ver.id, e); + e + })?; info!("Done downloading and verifying {}!", ver.id); |
