Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI(package/tag): Don't cache previously fetched user package #4996

Merged
merged 1 commit into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading