From 66062a642772dd74350b53ae055b32fe97aa0a45 Mon Sep 17 00:00:00 2001 From: objz Date: Thu, 29 Oct 2026 16:37:04 +0100 Subject: [PATCH] fix: avoid spurious warnings during instance installation --- src/instance/manager.rs | 2 +- src/net/mojang.rs | 4 ++-- tests/net_mojang.rs | 7 +++++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/instance/manager.rs b/src/instance/manager.rs index ab28933..a3d3d20 100644 --- a/src/instance/manager.rs +++ b/src/instance/manager.rs @@ -632,7 +632,7 @@ impl InstanceManager { let config_path = self.instances_dir.join(name).join("instance.json"); if !config_path.exists() { - tracing::warn!( + tracing::debug!( "Instance '{}' config is missing at {}", name, config_path.display() diff --git a/src/net/mojang.rs b/src/net/mojang.rs index acce1cd..f446812 100644 --- a/src/net/mojang.rs +++ b/src/net/mojang.rs @@ -522,8 +522,8 @@ pub async fn download_assets_from( serde_json::from_slice(&bytes).ok() } Ok(_) => { - tracing::warn!( - "Invalid cached asset index at {}; fetching again", + tracing::debug!( + "Cached asset index at {} does not match the requested version; fetching again", index_path.display() ); None diff --git a/tests/net_mojang.rs b/tests/net_mojang.rs index 25f450f..5685d2a 100644 --- a/tests/net_mojang.rs +++ b/tests/net_mojang.rs @@ -411,8 +411,11 @@ async fn download_assets_writes_index_when_objects_is_empty() { assert!(body.get("objects").is_some()); } +#[rstest::rstest] +#[case(b"{\"objects\":{\"fake\":{}}}")] +#[case(b"{\"objects\":{},\"virtual\":false}")] #[tokio::test] -async fn invalid_cached_index_is_refetched() { +async fn mismatched_cached_index_is_refetched(#[case] cached: &[u8]) { let server = MockServer::start().await; let body = serde_json::to_vec(&json!({"objects": {}})).unwrap(); Mock::given(method("GET")) @@ -426,7 +429,7 @@ async fn invalid_cached_index_is_refetched() { let tmp = tempfile::tempdir().unwrap(); let index_path = tmp.path().join("cache/minecraft/assets/indexes/5.json"); std::fs::create_dir_all(index_path.parent().unwrap()).unwrap(); - std::fs::write(&index_path, b"{\"objects\":{\"fake\":{}}}").unwrap(); + std::fs::write(&index_path, cached).unwrap(); download_assets(&HttpClient::new(), &meta, tmp.path()) .await