added: Fabric/Quilt raw-bytes profile storage + migration fix
stop re-serializing FabricProfile/QuiltProfile through narrow structs; new fetch_X_profile_with_raw helpers return both the parsed shape (for library downloads) and the upstream bytes (written byte-for-byte to the loader-profiles cache). also fixes a latent issue surfaced by the change: the legacy-loader migration predicate now skips Fabric and Quilt explicitly since their upstream shape matches the predicate but they have no installer JSON to recover from.
This commit is contained in:
1 parent
8d2b5b9832
commit
a7b378b17d
6 files changed
+164
-13
No files matched your search
@@ -77,6 +77,25 @@ pub async fn fetch_fabric_profile(
|
||||
client.get_json(&url).await
|
||||
}
|
||||
|
||||
// like fetch_fabric_profile 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. any future arguments field) by
|
||||
// re-serializing through our narrow FabricProfile struct.
|
||||
pub async fn fetch_fabric_profile_with_raw(
|
||||
client: &HttpClient,
|
||||
game_version: &str,
|
||||
loader_version: &str,
|
||||
) -> Result<(FabricProfile, Vec<u8>), NetError> {
|
||||
let url = format!(
|
||||
"{}/versions/loader/{}/{}/profile/json",
|
||||
FABRIC_META_BASE, game_version, loader_version
|
||||
);
|
||||
let raw = client.get_bytes(&url).await?;
|
||||
let parsed: FabricProfile = serde_json::from_slice(&raw)
|
||||
.map_err(|e| NetError::Parse(format!("Failed to parse Fabric profile: {e}")))?;
|
||||
Ok((parsed, raw))
|
||||
}
|
||||
|
||||
// each fabric library entry has a maven coordinate and a base url.
|
||||
// the coordinate gets resolved to a path and combined with the url to download.
|
||||
pub async fn download_fabric_libraries(
|
||||
|
||||
@@ -74,6 +74,25 @@ pub async fn fetch_quilt_profile(
|
||||
client.get_json(&url).await
|
||||
}
|
||||
|
||||
// like fetch_quilt_profile 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. any future arguments field) by
|
||||
// re-serializing through our narrow QuiltProfile struct.
|
||||
pub async fn fetch_quilt_profile_with_raw(
|
||||
client: &HttpClient,
|
||||
game_version: &str,
|
||||
loader_version: &str,
|
||||
) -> Result<(QuiltProfile, Vec<u8>), NetError> {
|
||||
let url = format!(
|
||||
"{}/versions/loader/{}/{}/profile/json",
|
||||
QUILT_META_BASE, game_version, loader_version
|
||||
);
|
||||
let raw = client.get_bytes(&url).await?;
|
||||
let parsed: QuiltProfile = serde_json::from_slice(&raw)
|
||||
.map_err(|e| NetError::Parse(format!("Failed to parse Quilt profile: {e}")))?;
|
||||
Ok((parsed, raw))
|
||||
}
|
||||
|
||||
pub async fn download_quilt_libraries(
|
||||
client: &HttpClient,
|
||||
profile: &QuiltProfile,
|
||||
|
||||
Reference in new issue
Block a user