fix: key cached version info by loader format version

Bump interfrost to 1.5.0 and pass the cluster's loader to download_version_info so a format bump doesn't reuse stale version JSON.
This commit is contained in:
Julian Chang 2026-10-01 01:34:40 -04:00
parent fc3046d60e
commit 67cfc4eb83
No known key found for this signature in database
7 changed files with 30 additions and 5 deletions

4
Cargo.lock generated
View file

@ -3619,9 +3619,9 @@ dependencies = [
[[package]]
name = "interfrost"
version = "1.4.0"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "76a14453cd2d9454beb9b410dc7b845b2d62ff67a6f42460bce6b9bc6e34d3b9"
checksum = "51cf4ffa08d3e23d9f6328cf64f521f7f50fb9ada957d0292e1738c40b699686"
dependencies = [
"chrono",
"serde",

View file

@ -37,7 +37,7 @@ polyio = {path = "./packages/polyio"}
# core (extra)
discord-rich-presence = {version = "=1.1.0"}
interfrost = {version = "=1.4.0"}
interfrost = {version = "=1.5.0"}
# logging
sentry = {version = "=0.49.3", default-features = false, features = [

View file

@ -258,7 +258,12 @@ impl QueryCapability for JavaMajorsQuery {
let mc = mc.clone();
async move {
let info = oneclient_core::game::download_version_info(
&mc, None, &version, None, false,
&mc,
None,
&version,
oneclient_common::domain::GameLoader::Vanilla,
None,
false,
)
.await
.ok()?;

View file

@ -188,6 +188,7 @@ pub async fn required_java_major(
&state.services.mc(),
None,
&version,
cluster.mc_loader,
loader_version.as_ref(),
false,
)
@ -222,6 +223,7 @@ pub async fn estimate_cluster_download(
&state.services.mc(),
None,
&version,
cluster.mc_loader,
loader_version.as_ref(),
false,
)
@ -279,6 +281,7 @@ async fn install_cluster(
&state.services.mc(),
Some(progress),
&version,
cluster.mc_loader,
loader_version.as_ref(),
force,
)

View file

@ -186,6 +186,7 @@ async fn start(
&state.services.mc(),
Some(&progress),
&version,
cluster.mc_loader,
loader_version.as_ref(),
false,
)

View file

@ -123,6 +123,7 @@ async fn run_verify(
&state.services.mc(),
Some(progress),
&version,
cluster.mc_loader,
loader_version.as_ref(),
false,
)

View file

@ -705,6 +705,7 @@ pub async fn download_version_info(
ctx: &McCtx,
progress: Option<&GroupedProgressSession>,
version: &Version,
game_loader: GameLoader,
loader: Option<&LoaderVersion>,
force: bool,
) -> McResult<VersionInfo> {
@ -714,7 +715,7 @@ pub async fn download_version_info(
let path = paths::versions_dir()?
.join(&version_id)
.join(format!("{version_id}.json"));
.join(version_info_file_name(&version_id, game_loader.get_format_version()));
if path.exists() && !force {
match polyio::read_json::<VersionInfo>(&path).await {
@ -1540,10 +1541,24 @@ pub fn is_version_updated(version_index: usize, versions: &[Version]) -> bool {
version_index <= versions.iter().position(|x| x.id == "22w16a").unwrap_or(0)
}
fn version_info_file_name(version_id: &str, format_version: usize) -> String {
if format_version == 0 {
format!("{version_id}.json")
} else {
format!("{version_id}.v{format_version}.json")
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn a_format_bump_moves_the_cached_version_info() {
assert_eq!(version_info_file_name("1.8.9", 0), "1.8.9.json");
assert_eq!(version_info_file_name("1.8.9-0.19.5", 1), "1.8.9-0.19.5.v1.json");
}
fn scratch(tag: &str) -> PathBuf {
let dir =
std::env::temp_dir().join(format!("oneclient-install-{tag}-{}", uuid::Uuid::new_v4()));