mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-09 22:28:21 +00:00
Add --force install method (download packages without cooldown)
This commit is contained in:
@@ -267,7 +267,7 @@ fn try_run_package_or_file(args: &[String], r: &Run) -> Result<(), anyhow::Error
|
||||
}
|
||||
|
||||
// else: local package not found - try to download and install package
|
||||
try_autoinstall_package(args, &sv, package_download_info)
|
||||
try_autoinstall_package(args, &sv, package_download_info, r.force_install)
|
||||
}
|
||||
|
||||
fn try_lookup_command(sv: &mut SplitVersion) -> Result<PackageDownloadInfo, anyhow::Error> {
|
||||
@@ -317,10 +317,11 @@ fn try_autoinstall_package(
|
||||
args: &[String],
|
||||
sv: &SplitVersion,
|
||||
package: Option<PackageDownloadInfo>,
|
||||
force_install: bool,
|
||||
) -> Result<(), anyhow::Error> {
|
||||
let sp = start_spinner(format!("Installing package {} ...", sv.package));
|
||||
let v = sv.version.as_deref();
|
||||
let result = wasmer_registry::install_package(&sv.package, v, package);
|
||||
let result = wasmer_registry::install_package(&sv.package, v, package, force_install);
|
||||
sp.close();
|
||||
print!("\r\n");
|
||||
let (package, buf) = match result {
|
||||
|
||||
@@ -25,6 +25,10 @@ use wasi::Wasi;
|
||||
/// Same as `wasmer run`, but without the required `path` argument (injected previously)
|
||||
#[derive(Debug, Parser, Clone, Default)]
|
||||
pub struct RunWithoutFile {
|
||||
/// When installing packages with `wasmer $package`, force re-downloading the package
|
||||
#[clap(long = "force", short = 'f')]
|
||||
pub(crate) force_install: bool,
|
||||
|
||||
/// Disable the cache
|
||||
#[cfg(feature = "cache")]
|
||||
#[clap(long = "disable-cache")]
|
||||
@@ -147,6 +151,7 @@ impl RunWithoutFile {
|
||||
Run {
|
||||
path: pathbuf,
|
||||
options: RunWithoutFile {
|
||||
force_install: self.force_install,
|
||||
#[cfg(feature = "cache")]
|
||||
disable_cache: self.disable_cache,
|
||||
invoke: self.invoke,
|
||||
|
||||
@@ -904,6 +904,7 @@ pub fn install_package(
|
||||
name: &str,
|
||||
version: Option<&str>,
|
||||
package_download_info: Option<PackageDownloadInfo>,
|
||||
force_install: bool,
|
||||
) -> Result<(LocalPackage, PathBuf), String> {
|
||||
let package_info = match package_download_info {
|
||||
Some(s) => s,
|
||||
@@ -932,6 +933,7 @@ pub fn install_package(
|
||||
continue;
|
||||
}
|
||||
|
||||
if !force_install {
|
||||
match get_if_package_has_new_version(
|
||||
r,
|
||||
name,
|
||||
@@ -944,6 +946,7 @@ pub fn install_package(
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
match query_package_from_registry(r, name, version) {
|
||||
Ok(o) => {
|
||||
|
||||
Reference in New Issue
Block a user