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 3a098eb
Showing 1 changed file with 4 additions and 15 deletions.
19 changes: 4 additions & 15 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 Expand Up @@ -921,12 +915,7 @@ mod tests {
name: "wasmer-pack".to_string(),
},],
entrypoint: Some("wasmer-pack".to_string()),
filesystem: vec![FileSystemMapping {
volume_name: "atom".to_string(),
mount_path: "/".to_string(),
original_path: Some("/".to_string()),
dependency_name: None,
}],
filesystem: vec![],
},
dist: DistributionInfo {
webc: "https://storage.googleapis.com/wapm-registry-prod/webc/wasmer/wasmer-pack-cli/0.6.0/wasmer-pack-cli-0.6.0.webc"
Expand Down

0 comments on commit 3a098eb

Please sign in to comment.