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:
1 parent
19887643bc
commit
412e6ff91a
12 files changed
+395
-74
No files matched your search
+8
-30
@@ -113,17 +113,10 @@ pub async fn fetch_version_manifest(client: &HttpClient) -> Result<VersionManife
|
||||
client.get_json(MANIFEST_URL).await
|
||||
}
|
||||
|
||||
pub async fn fetch_version_meta(
|
||||
client: &HttpClient,
|
||||
entry: &VersionEntry,
|
||||
) -> Result<VersionMeta, NetError> {
|
||||
client.get_json(&entry.url).await
|
||||
}
|
||||
|
||||
// like fetch_version_meta but also returns the raw response bytes so the
|
||||
// caller can write the upstream JSON byte-for-byte to disk. used by the
|
||||
// install path so we don't lose data (e.g. arguments.jvm) by re-serializing
|
||||
// through our narrow VersionMeta struct.
|
||||
// fetches and parses a version's metadata. also returns the raw response
|
||||
// bytes so the caller can write the upstream JSON byte-for-byte to disk
|
||||
// - used by the install path so we don't lose data (e.g. arguments.jvm)
|
||||
// by re-serializing through our narrow VersionMeta struct.
|
||||
pub async fn fetch_version_meta_with_raw(
|
||||
client: &HttpClient,
|
||||
entry: &VersionEntry,
|
||||
@@ -173,9 +166,11 @@ pub async fn download_libraries(
|
||||
set_action("Downloading libraries...");
|
||||
|
||||
let features = crate::launch_profile::rules::FeatureSet::default();
|
||||
let host_os_version = crate::launch_profile::system::mojang_os_version();
|
||||
let rule_ctx = crate::launch_profile::rules::RuleContext {
|
||||
os_name: mojang_os_name(),
|
||||
arch: mojang_arch_name(),
|
||||
os_name: crate::launch_profile::system::mojang_os_name(),
|
||||
os_version: &host_os_version,
|
||||
arch: crate::launch_profile::system::mojang_arch_name(),
|
||||
features: &features,
|
||||
};
|
||||
|
||||
@@ -293,23 +288,6 @@ pub async fn download_assets(
|
||||
result
|
||||
}
|
||||
|
||||
// mojang calls macOS "osx" because apparently it's still 2012
|
||||
fn mojang_os_name() -> &'static str {
|
||||
match std::env::consts::OS {
|
||||
"macos" => "osx",
|
||||
other => other,
|
||||
}
|
||||
}
|
||||
|
||||
fn mojang_arch_name() -> &'static str {
|
||||
match std::env::consts::ARCH {
|
||||
"x86" => "x86",
|
||||
"x86_64" => "x86_64",
|
||||
"aarch64" => "arm64",
|
||||
other => other,
|
||||
}
|
||||
}
|
||||
|
||||
// bounded parallel downloader. spawns up to MAX_CONCURRENT_DOWNLOADS tasks
|
||||
// and feeds new ones in as each completes. collects errors but keeps going
|
||||
// so it downloads as much as possible before reporting the first failure.
|
||||
|
||||
Reference in new issue
Block a user