mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-07 13:18:20 +00:00
Address review comments from https://github.com/wasmerio/wasmer/pull/3299#pullrequestreview-1186599785
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -3993,7 +3993,6 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"spinner",
|
"spinner",
|
||||||
"tar",
|
|
||||||
"target-lexicon 0.12.4",
|
"target-lexicon 0.12.4",
|
||||||
"tempdir",
|
"tempdir",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ log = { version = "0.4", optional = true }
|
|||||||
tempfile = "3"
|
tempfile = "3"
|
||||||
tempdir = "0.3.7"
|
tempdir = "0.3.7"
|
||||||
http_req = { version="^0.8", default-features = false, features = ["rust-tls"], optional = true }
|
http_req = { version="^0.8", default-features = false, features = ["rust-tls"], optional = true }
|
||||||
reqwest = { version = "^0.11", default-features = false, features = ["rustls-tls", "json"], optional = true }
|
reqwest = { version = "^0.11", default-features = false, features = ["rustls-tls", "json", "multipart"], optional = true }
|
||||||
serde = { version = "1.0.147", features = ["derive"], optional = true }
|
serde = { version = "1.0.147", features = ["derive"], optional = true }
|
||||||
dirs = { version = "4.0", optional = true }
|
dirs = { version = "4.0", optional = true }
|
||||||
serde_json = { version = "1.0", optional = true }
|
serde_json = { version = "1.0", optional = true }
|
||||||
@@ -71,7 +71,6 @@ libc = { version = "^0.2", default-features = false }
|
|||||||
nuke-dir = { version = "0.1.0", optional = true }
|
nuke-dir = { version = "0.1.0", optional = true }
|
||||||
webc = { version = "3.0.1", optional = true }
|
webc = { version = "3.0.1", optional = true }
|
||||||
isatty = "0.1.9"
|
isatty = "0.1.9"
|
||||||
tar = "0.4"
|
|
||||||
dialoguer = "0.10.2"
|
dialoguer = "0.10.2"
|
||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
|
|||||||
@@ -548,8 +548,6 @@ impl CreateExe {
|
|||||||
header_code_path = std::env::current_dir()?;
|
header_code_path = std::env::current_dir()?;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("Output result to: {}", output_path.display());
|
|
||||||
|
|
||||||
/* Compile main function */
|
/* Compile main function */
|
||||||
let compilation = {
|
let compilation = {
|
||||||
let mut include_dir = libwasmer_path.clone();
|
let mut include_dir = libwasmer_path.clone();
|
||||||
@@ -591,7 +589,8 @@ impl CreateExe {
|
|||||||
cmd.arg(volume_obj.clone());
|
cmd.arg(volume_obj.clone());
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("{:?}", cmd);
|
#[cfg(feature = "debug")]
|
||||||
|
log::debug!("{:?}", cmd);
|
||||||
cmd.output().context("Could not execute `zig`")?
|
cmd.output().context("Could not execute `zig`")?
|
||||||
};
|
};
|
||||||
if !compilation.status.success() {
|
if !compilation.status.success() {
|
||||||
@@ -1387,7 +1386,8 @@ mod http_fetch {
|
|||||||
.context("Could not lookup wasmer repository on Github.")?;
|
.context("Could not lookup wasmer repository on Github.")?;
|
||||||
|
|
||||||
if response.status_code() != StatusCode::new(200) {
|
if response.status_code() != StatusCode::new(200) {
|
||||||
eprintln!(
|
#[cfg(feature = "debug")]
|
||||||
|
log::warn!(
|
||||||
"Warning: Github API replied with non-200 status code: {}. Response: {}",
|
"Warning: Github API replied with non-200 status code: {}. Response: {}",
|
||||||
response.status_code(),
|
response.status_code(),
|
||||||
String::from_utf8_lossy(&writer),
|
String::from_utf8_lossy(&writer),
|
||||||
@@ -1565,32 +1565,30 @@ mod http_fetch {
|
|||||||
.to_string();
|
.to_string();
|
||||||
|
|
||||||
let download_tempdir = tempdir::TempDir::new("wasmer-download")?;
|
let download_tempdir = tempdir::TempDir::new("wasmer-download")?;
|
||||||
let download_path = download_tempdir.path().to_path_buf().join(&filename);
|
let download_path = download_tempdir.path().join(&filename);
|
||||||
|
|
||||||
let mut file = std::fs::File::create(&download_path)?;
|
let mut file = std::fs::File::create(&download_path)?;
|
||||||
eprintln!(
|
#[cfg(feature = "debug")]
|
||||||
|
log::debug!(
|
||||||
"Downloading {} to {}",
|
"Downloading {} to {}",
|
||||||
browser_download_url,
|
browser_download_url,
|
||||||
download_path.display()
|
download_path.display()
|
||||||
);
|
);
|
||||||
|
|
||||||
let uri = Uri::try_from(browser_download_url.as_str())?;
|
let mut response = reqwest::blocking::Client::builder()
|
||||||
let mut response = Request::new(&uri)
|
.redirect(reqwest::redirect::Policy::limited(10))
|
||||||
.header("User-Agent", "wasmer")
|
.timeout(std::time::Duration::from_secs(10))
|
||||||
.send(&mut file)
|
.build()
|
||||||
|
.map_err(anyhow::Error::new)
|
||||||
|
.context("Could not lookup wasmer artifact on Github.")?
|
||||||
|
.get(browser_download_url.as_str())
|
||||||
|
.send()
|
||||||
.map_err(anyhow::Error::new)
|
.map_err(anyhow::Error::new)
|
||||||
.context("Could not lookup wasmer artifact on Github.")?;
|
.context("Could not lookup wasmer artifact on Github.")?;
|
||||||
if response.status_code() == StatusCode::new(302) {
|
|
||||||
let redirect_uri =
|
|
||||||
Uri::try_from(response.headers().get("Location").unwrap().as_str()).unwrap();
|
|
||||||
response = Request::new(&redirect_uri)
|
|
||||||
.header("User-Agent", "wasmer")
|
|
||||||
.send(&mut file)
|
|
||||||
.map_err(anyhow::Error::new)
|
|
||||||
.context("Could not lookup wasmer artifact on Github.")?;
|
|
||||||
}
|
|
||||||
|
|
||||||
let _ = response;
|
response
|
||||||
|
.copy_to(&mut file)
|
||||||
|
.map_err(|e| anyhow::anyhow!("{e}"))?;
|
||||||
|
|
||||||
match super::get_libwasmer_cache_path() {
|
match super::get_libwasmer_cache_path() {
|
||||||
Ok(mut cache_path) => {
|
Ok(mut cache_path) => {
|
||||||
|
|||||||
@@ -710,12 +710,6 @@ pub fn download_and_unpack_targz(
|
|||||||
let mut resp = reqwest::blocking::get(url)
|
let mut resp = reqwest::blocking::get(url)
|
||||||
.map_err(|e| anyhow::anyhow!("failed to download {url}: {e}"))?;
|
.map_err(|e| anyhow::anyhow!("failed to download {url}: {e}"))?;
|
||||||
|
|
||||||
if !target_targz_path.exists() {
|
|
||||||
// create all the parent paths, only remove the created directory, not the parent dirs
|
|
||||||
let _ = std::fs::create_dir_all(&target_targz_path);
|
|
||||||
let _ = std::fs::remove_dir(&target_targz_path);
|
|
||||||
}
|
|
||||||
|
|
||||||
{
|
{
|
||||||
let mut file = std::fs::File::create(&target_targz_path).map_err(|e| {
|
let mut file = std::fs::File::create(&target_targz_path).map_err(|e| {
|
||||||
anyhow::anyhow!(
|
anyhow::anyhow!(
|
||||||
@@ -729,7 +723,7 @@ pub fn download_and_unpack_targz(
|
|||||||
}
|
}
|
||||||
|
|
||||||
try_unpack_targz(target_targz_path.as_path(), target_path, strip_toplevel)
|
try_unpack_targz(target_targz_path.as_path(), target_path, strip_toplevel)
|
||||||
.context(anyhow::anyhow!("Could not download {url}"))?;
|
.with_context(|| anyhow::anyhow!("Could not download {url}"))?;
|
||||||
|
|
||||||
Ok(target_path.to_path_buf())
|
Ok(target_path.to_path_buf())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user