fix: force index refresh on install, fetch once for multi-package installs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Breadway 2026-06-07 15:23:54 +08:00
parent 7a17fcaa93
commit a4ea036a7c

View file

@ -63,8 +63,9 @@ fn main() -> Result<()> {
match cli.command { match cli.command {
Cmd::Install { packages } => { Cmd::Install { packages } => {
let index = manifest::load(true)?;
for pkg in &packages { for pkg in &packages {
cmd_install(pkg, &bin_dir)?; cmd_install(&index, pkg, &bin_dir)?;
} }
Ok(()) Ok(())
} }
@ -76,8 +77,7 @@ fn main() -> Result<()> {
} }
} }
fn cmd_install(name: &str, bin_dir: &std::path::Path) -> Result<()> { fn cmd_install(index: &manifest::Index, name: &str, bin_dir: &std::path::Path) -> Result<()> {
let index = manifest::load(false)?;
let pkg = index let pkg = index
.get(name) .get(name)
.ok_or_else(|| anyhow::anyhow!("unknown package: {name}"))?; .ok_or_else(|| anyhow::anyhow!("unknown package: {name}"))?;