fixed: review findings - robustness, dead code, missing tests

several smaller fixes from the code review:
 - add os_version to RuleContext + OsCondition for mojang rules that
   constrain natives selection by host version (rare, but in the spec).
 - factor mojang_os_name/arch/version into a shared launch_profile::system
   module instead of duplicating between net/mojang.rs and launch/mod.rs.
 - get_json and get_bytes now retry transient failures (5xx, connect,
   body decode) via a shared get_with_retry envelope; previously only
   download_file had retry logic.
 - migrate_legacy_meta_if_needed falls back to the stale cached profile
   with a warn log on network failure instead of erroring out (offline
   launches now work).
 - tightened legacy-loader detection by requiring the unique-to-rmcl
   gameArguments field; clearer error when loader_version is absent.
 - forge legacy versionInfo write uses compact serialization (no
   pretty-print key reorder).
 - deleted dead fetch_version_meta and save_profile_json.
 - documented quick-play templates omission in templates::lookup.
 - added end-to-end test that loads a vanilla profile from disk, loads a
   loader profile with inheritsFrom, resolves, renders, and snapshots.
This commit is contained in:
objz committed 2026-05-25 18:24:06 +02:00
1 parent 19887643bc
commit 412e6ff91a
12 files changed
+395 -74

No files matched your search

+9 -15
View File
@@ -46,20 +46,6 @@ pub trait ModLoaderInstaller: Send + Sync {
) -> Result<(), NetError>;
}
pub(crate) fn save_profile_json(
meta_dir: &Path,
filename: &str,
profile: &impl serde::Serialize,
) -> Result<(), NetError> {
let profiles_dir = meta_dir.join("loader-profiles");
std::fs::create_dir_all(&profiles_dir)?;
let profile_path = profiles_dir.join(filename);
let json = serde_json::to_string_pretty(profile)
.map_err(|e| NetError::Parse(format!("Failed to serialize profile {filename}: {e}")))?;
std::fs::write(&profile_path, &json)?;
Ok(())
}
// used by forge/neoforge. their java installer drops a version json into
// .minecraft/versions/. we copy that file byte-for-byte to our loader
// profile cache so launch-time code sees the full upstream JSON -
@@ -214,7 +200,15 @@ mod tests {
]
});
save_profile_json(&meta_dir, "forge-1.7.10-10.13.4.1614.json", &version_info).unwrap();
// mirror the install path: write versionInfo as compact JSON.
let profiles_dir = meta_dir.join("loader-profiles");
std::fs::create_dir_all(&profiles_dir).unwrap();
let serialized = serde_json::to_vec(&version_info).unwrap();
std::fs::write(
profiles_dir.join("forge-1.7.10-10.13.4.1614.json"),
&serialized,
)
.unwrap();
let saved_bytes = std::fs::read(
meta_dir