mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-07 13:18:20 +00:00
Fix panic if WASMER_DIR does not exist
This commit is contained in:
@@ -1614,26 +1614,40 @@ pub(super) mod utils {
|
|||||||
Some(tarball_dir.join(&filename))
|
Some(tarball_dir.join(&filename))
|
||||||
} else {
|
} else {
|
||||||
println!("create exe 4.0");
|
println!("create exe 4.0");
|
||||||
// check if the tarball for the target already exists locally
|
let wasmer_cache_dir =
|
||||||
let local_tarball = std::fs::read_dir(
|
|
||||||
if *target_triple == Triple::host() && std::env::var("WASMER_DIR").is_ok() {
|
if *target_triple == Triple::host() && std::env::var("WASMER_DIR").is_ok() {
|
||||||
wasmer_registry::WasmerConfig::get_wasmer_dir()
|
wasmer_registry::WasmerConfig::get_wasmer_dir()
|
||||||
.map_err(|e| anyhow::anyhow!("{e}"))?
|
.map_err(|e| anyhow::anyhow!("{e}"))
|
||||||
.join("cache")
|
.map(|o| o.join("cache"))
|
||||||
} else {
|
} else {
|
||||||
get_libwasmer_cache_path()?
|
get_libwasmer_cache_path()
|
||||||
},
|
|
||||||
)?
|
|
||||||
.filter_map(|e| e.ok())
|
|
||||||
.filter_map(|e| {
|
|
||||||
let path = format!("{}", e.path().display());
|
|
||||||
if path.ends_with(".tar.gz") {
|
|
||||||
Some(e.path())
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
}
|
||||||
})
|
.ok();
|
||||||
.find(|p| crate::commands::utils::filter_tarball(p, target));
|
|
||||||
|
println!("wasmer_cache_dir: {:?}", wasmer_cache_dir);
|
||||||
|
println!(
|
||||||
|
"exists: {:?}",
|
||||||
|
wasmer_cache_dir
|
||||||
|
.as_ref()
|
||||||
|
.map(|wc| wc.exists())
|
||||||
|
.unwrap_or(false)
|
||||||
|
);
|
||||||
|
|
||||||
|
// check if the tarball for the target already exists locally
|
||||||
|
let local_tarball = wasmer_cache_dir.as_ref().and_then(|wc| {
|
||||||
|
let wasmer_cache = std::fs::read_dir(wc).ok()?;
|
||||||
|
wasmer_cache
|
||||||
|
.filter_map(|e| e.ok())
|
||||||
|
.filter_map(|e| {
|
||||||
|
let path = format!("{}", e.path().display());
|
||||||
|
if path.ends_with(".tar.gz") {
|
||||||
|
Some(e.path())
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.find(|p| crate::commands::utils::filter_tarball(p, target))
|
||||||
|
});
|
||||||
|
|
||||||
println!("create exe 4.1");
|
println!("create exe 4.1");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user