Skip to content

Commit

Permalink
fix(wasix): Fix incorrect webc version mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
theduke committed Jul 8, 2024
1 parent 617173d commit 3b6b2f5
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions lib/wasix/src/runtime/resolver/backend_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -364,32 +364,30 @@ fn decode_summary(
let WebQueryGetPackageVersion {
v2:
WebQueryGetPackageVersionDistribution {
webc_version: v2_webc_version,
pirita_sha256_hash: v2_pirita_sha256_hash,
pirita_download_url: v2_pirita_download_url,
webc_manifest: v2_manifest,
},
v3:
WebQueryGetPackageVersionDistribution {
webc_version: v3_webc_version,
pirita_sha256_hash: v3_pirita_sha256_hash,
pirita_download_url: v3_pirita_download_url,
webc_manifest: v3_manifest,
},
..
} = pkg_version;

let (webc_version, pirita_sha256_hash, pirita_download_url, manifest) =
let (version, pirita_sha256_hash, pirita_download_url, manifest) =
if preferred_webc_version == webc::Version::V3 {
(
v3_webc_version,
webc::Version::V3,
v3_pirita_sha256_hash,
v3_pirita_download_url,
v3_manifest,
)
} else {
(
v2_webc_version,
webc::Version::V2,
v2_pirita_sha256_hash,
v2_pirita_download_url,
v2_manifest,
Expand All @@ -413,8 +411,6 @@ fn decode_summary(

let webc_sha256 = WebcHash::parse_hex(&hash).context("invalid webc sha256 hash in manifest")?;

let version: webc::Version = webc_version.unwrap_or_default().into();

Ok(PackageSummary {
pkg: PackageInfo::from_manifest(id, &manifest, version)?,
dist: DistributionInfo { webc, webc_sha256 },
Expand Down Expand Up @@ -705,8 +701,6 @@ impl From<WebCVersion> for webc::Version {

#[derive(Debug, serde::Serialize, serde::Deserialize, Clone)]
pub struct WebQueryGetPackageVersionDistribution {
#[serde(rename = "webcVersion")]
pub webc_version: Option<WebCVersion>,
#[serde(rename = "piritaDownloadUrl")]
pub pirita_download_url: Option<Url>,
#[serde(rename = "piritaSha256Hash")]
Expand Down

0 comments on commit 3b6b2f5

Please sign in to comment.