Skip to content
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
68 changes: 38 additions & 30 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ hex = "0.4"
humansize = "2"
indenter = "0.3"
indexmap = { version = "2", features = ["serde"] }
indicatif = { version = "0.18", features = ["improved_unicode"] }
clx = "1"
indoc = "2"
itertools = "0.14"
jiff = "0.2"
Expand Down
10 changes: 9 additions & 1 deletion mise.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

70 changes: 43 additions & 27 deletions src/backend/aqua.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,30 @@ impl Backend for AquaBackend {
.and_then(|p| p.description.clone())
}

async fn install_operation_count(&self, tv: &ToolVersion, _ctx: &InstallContext) -> usize {
let pkg = match AQUA_REGISTRY
.package_with_version(&self.id, &[&tv.version])
.await
{
Ok(pkg) => pkg,
Err(_) => return 3, // fallback to default
};
let format = pkg.format(&tv.version, os(), arch()).unwrap_or_default();

let mut count = 1; // download
// Count checksum operation if explicitly configured OR if this is a GitHub release
// (GitHub API may provide a digest even without explicit checksum config)
if pkg.checksum.as_ref().is_some_and(|c| c.enabled())
|| pkg.r#type == AquaPackageType::GithubRelease
{
count += 1;
}
Comment thread
cursor[bot] marked this conversation as resolved.
if needs_extraction(format, &pkg.r#type) {
count += 1;
}
Comment thread
cursor[bot] marked this conversation as resolved.
count
}

async fn security_info(&self) -> Vec<crate::backend::SecurityFeature> {
use crate::backend::SecurityFeature;

Expand Down Expand Up @@ -410,24 +434,30 @@ impl Backend for AquaBackend {
(url, v.to_string(), filename, digest)
};

// Determine operation count for progress reporting
let format = pkg.format(&v, os(), arch()).unwrap_or_default();
let op_count = Self::calculate_op_count(&pkg, &api_digest, format);
ctx.pr.start_operations(op_count);

self.download(ctx, &tv, &url, &filename).await?;

if validated_url.is_none() {
// Store the asset URL and digest (if available) in the tool version
let platform_info = tv.lock_platforms.entry(platform_key).or_default();
platform_info.url = Some(url.clone());
if let Some(digest) = api_digest {
if let Some(digest) = api_digest.clone() {
debug!("using GitHub API digest for checksum verification");
platform_info.checksum = Some(digest);
}
}

// Advance to checksum operation if applicable
if pkg.checksum.as_ref().is_some_and(|c| c.enabled()) || api_digest.is_some() {
ctx.pr.next_operation();
}
self.verify(ctx, &mut tv, &pkg, &v, &filename).await?;

// Advance to extraction operation if applicable
if needs_extraction(format, &pkg.r#type) {
ctx.pr.next_operation();
}
self.install(ctx, &tv, &pkg, &v, &filename)?;

Ok(tv)
Expand Down Expand Up @@ -695,29 +725,6 @@ impl AquaBackend {
}
}

/// Calculate the number of operations for progress reporting.
/// Operations: download (always), checksum (if enabled or api_digest), extraction (if needed)
fn calculate_op_count(pkg: &AquaPackage, api_digest: &Option<String>, format: &str) -> usize {
let mut op_count = 1; // download

// Checksum verification (from pkg config or GitHub API digest)
if pkg.checksum.as_ref().is_some_and(|c| c.enabled()) || api_digest.is_some() {
op_count += 1;
}

// Extraction (for archives, or GithubArchive/GithubContent which always extract)
if (!format.is_empty() && format != "raw")
|| matches!(
pkg.r#type,
AquaPackageType::GithubArchive | AquaPackageType::GithubContent
)
{
op_count += 1;
}

op_count
}

async fn github_release_url(
&self,
pkg: &AquaPackage,
Expand Down Expand Up @@ -1620,6 +1627,15 @@ fn resolve_repo_info(
(owner, name)
}

/// Check if extraction is needed based on format and package type.
fn needs_extraction(format: &str, pkg_type: &AquaPackageType) -> bool {
(!format.is_empty() && format != "raw")
|| matches!(
pkg_type,
AquaPackageType::GithubArchive | AquaPackageType::GithubContent
)
}

/// Check if a platform is supported by the package's supported_envs.
/// Returns true if supported, false if not.
fn is_platform_supported(supported_envs: &[String], os: &str, arch: &str) -> bool {
Expand Down
31 changes: 5 additions & 26 deletions src/backend/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,35 +383,10 @@ impl UnifiedGitBackend {
let filename = asset.name.clone();
let file_path = tv.download_path().join(&filename);

// Count operations dynamically:
// 1. Download (always)
// 2. Verify checksum (if checksum option present)
// 3. Extract/install (if file needs extraction)
let mut op_count = 1; // download

// Check if we'll verify checksum
let has_checksum = lookup_platform_key(opts, "checksum")
.or_else(|| opts.get("checksum").cloned())
.is_some();
if has_checksum {
op_count += 1;
}
Comment thread
cursor[bot] marked this conversation as resolved.

// Check if we'll extract (archives need extraction)
let needs_extraction = filename.ends_with(".tar.gz")
|| filename.ends_with(".tar.xz")
|| filename.ends_with(".tar.bz2")
|| filename.ends_with(".tar.zst")
|| filename.ends_with(".tar")
|| filename.ends_with(".tgz")
|| filename.ends_with(".txz")
|| filename.ends_with(".tbz2")
|| filename.ends_with(".zip");
if needs_extraction {
op_count += 1;
}

ctx.pr.start_operations(op_count);

// Store the asset URL and digest (if available) in the tool version
let platform_key = self.get_platform_key();
Expand Down Expand Up @@ -473,13 +448,17 @@ impl UnifiedGitBackend {
.await?;

// Verify and install
verify_artifact(tv, &file_path, opts, Some(ctx.pr.as_ref()))?;
ctx.pr.next_operation();
if has_checksum {
verify_artifact(tv, &file_path, opts, Some(ctx.pr.as_ref()))?;
}
self.verify_checksum(ctx, tv, &file_path)?;

// Verify attestations or SLSA (check attestations first, fall back to SLSA)
self.verify_attestations_or_slsa(ctx, tv, &file_path)
.await?;

ctx.pr.next_operation();
install_artifact(tv, &file_path, opts, Some(ctx.pr.as_ref()))?;

if let Some(bins) = self.get_filter_bins(tv) {
Expand Down
Loading
Loading