Skip to content

Commit

Permalink
fix(package/tag): Remove harmful cache
Browse files Browse the repository at this point in the history
  • Loading branch information
xdoardo authored and theduke committed Aug 15, 2024
1 parent ea574cf commit f6fe9ea
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
1 change: 0 additions & 1 deletion lib/cli/src/commands/package/publish.rs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ impl PackagePublish {
package_path: self.package_path.clone(),
package_hash,
package_id: None,
maybe_user_package: None,
}
.tag(
client,
Expand Down
33 changes: 14 additions & 19 deletions lib/cli/src/commands/package/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use std::{
path::{Path, PathBuf},
str::FromStr,
};
use wasmer_api::{types::PackageVersionWithPackage, WasmerClient};
use wasmer_api::WasmerClient;
use wasmer_config::package::{
Manifest, NamedPackageId, NamedPackageIdent, PackageBuilder, PackageHash, PackageIdent,
};
Expand Down Expand Up @@ -85,10 +85,6 @@ pub struct PackageTag {
value_enum
)]
pub wait: PublishWait,

#[clap(skip)]
/// The package related to the NamedPackageId the user chose to tag.
pub(crate) maybe_user_package: Option<PackageVersionWithPackage>,
}

impl PackageTag {
Expand Down Expand Up @@ -152,6 +148,7 @@ impl PackageTag {
Ok(Some(new_manifest))
}

#[tracing::instrument]
async fn do_tag(
&self,
client: &WasmerClient,
Expand Down Expand Up @@ -438,8 +435,6 @@ impl PackageTag {
.as_ref()
.and_then(|p| p.distribution_v3.pirita_sha256_hash.clone());

self.maybe_user_package = maybe_pkg;

if let Some(hash) = maybe_hash {
let registry_package_hash = PackageHash::from_str(&format!("sha256:{hash}"))?;
registry_package_hash != self.package_hash
Expand Down Expand Up @@ -586,6 +581,7 @@ impl PackageTag {

// Check if a package with the same hash, namespace, name and version already exists. In such a
// case, don't tag the package again.
#[tracing::instrument]
async fn should_tag(&self, client: &WasmerClient, id: &NamedPackageId) -> anyhow::Result<bool> {
if self.dry_run {
if !self.quiet {
Expand All @@ -594,21 +590,20 @@ impl PackageTag {
return Ok(false);
}

let hash = if let Some(pkg) = self.maybe_user_package.as_ref() {
pkg.distribution_v3.pirita_sha256_hash.clone()
} else {
wasmer_api::query::get_package_version(
client,
id.full_name.clone(),
id.version.to_string(),
)
.await?
.and_then(|p| p.distribution_v3.pirita_sha256_hash)
};
let pkg = wasmer_api::query::get_package_version(
client,
id.full_name.clone(),
id.version.to_string(),
)
.await?;

if let Some(hash) = hash {
if let Some(hash) = pkg
.as_ref()
.and_then(|p| p.distribution_v3.pirita_sha256_hash.as_ref())
{
let registry_package_hash = PackageHash::from_str(&format!("sha256:{hash}"))?;
if registry_package_hash == self.package_hash {
tracing::info!("decided not to tag as package {pkg:?} already exists");
return Ok(false);
}
}
Expand Down

0 comments on commit f6fe9ea

Please sign in to comment.