From 2d29f3a5c7411a8b82a3c10c19f47d122adb4adf Mon Sep 17 00:00:00 2001 From: LynithDev <61880709+LynithDev@users.noreply.github.com> Date: Wed, 18 Dec 2024 16:00:57 +0100 Subject: [PATCH] fix: Downloading fallback + better logging in production --- packages/core/src/game/metadata.rs | 2 ++ packages/core/src/logger.rs | 3 ++- packages/core/src/utils/http.rs | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/core/src/game/metadata.rs b/packages/core/src/game/metadata.rs index 6ebab90a..c0d750e8 100644 --- a/packages/core/src/game/metadata.rs +++ b/packages/core/src/game/metadata.rs @@ -265,6 +265,7 @@ pub async fn download_libraries( artifact: Some(ref artifact), .. }) = lib.downloads { if !artifact.url.is_empty() { + tracing::info!("fetching library '{}' from '{}'", &lib.name, &artifact.url); let bytes = fetch(&artifact.url, Some(&artifact.sha1), &st.fetch_semaphore).await?; write(&path, &bytes, &st.io_semaphore).await?; tracing::trace!("fetched library {} to path {:?}", &lib.name, &path); @@ -272,6 +273,7 @@ pub async fn download_libraries( } } + tracing::info!("fetching #2 library '{}' from '{}'", &lib.name, &artifact.url); let url = [lib.url.as_deref().unwrap_or("https://libraries.minecraft.net/"), &artifact_path].concat(); let bytes = fetch(&url, None, &st.fetch_semaphore).await?; write(&path, &bytes, &st.io_semaphore).await?; diff --git a/packages/core/src/logger.rs b/packages/core/src/logger.rs index 742a37ca..c29808b3 100644 --- a/packages/core/src/logger.rs +++ b/packages/core/src/logger.rs @@ -28,7 +28,7 @@ pub fn start_logger() -> Option { }); let subscriber = tracing_subscriber::registry() - .with(tracing_subscriber::fmt::layer()) + .with(tracing_subscriber::fmt::layer().pretty()) .with(filter) .with(tracing_error::ErrorLayer::default()); @@ -59,6 +59,7 @@ pub fn start_logger() -> Option { let (non_blocking, guard) = tracing_appender::non_blocking(file_appender); let subscriber = tracing_subscriber::registry() + .with(tracing_subscriber::fmt::layer().pretty()) .with( tracing_subscriber::fmt::layer() .with_writer(non_blocking) diff --git a/packages/core/src/utils/http.rs b/packages/core/src/utils/http.rs index 280c4aa6..9a6ef546 100644 --- a/packages/core/src/utils/http.rs +++ b/packages/core/src/utils/http.rs @@ -106,6 +106,8 @@ pub async fn fetch_advanced( match result { Ok(x) => { + let x = x.error_for_status()?; + let bytes = if let Some((feed, total)) = &ingress { let length = x.content_length(); if let Some(total_size) = length {