mirror of
https://github.com/mii443/wasmer.git
synced 2025-12-07 21:28:21 +00:00
Remove threading when dowloading release to prevent unexpected failure
This commit is contained in:
@@ -1567,32 +1567,36 @@ mod http_fetch {
|
|||||||
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().to_path_buf().join(&filename);
|
||||||
let mut file = std::fs::File::create(&download_path)?;
|
let mut file = std::fs::File::create(&download_path)?;
|
||||||
println!("Downloading {} to {}", browser_download_url, download_path.display());
|
println!(
|
||||||
let download_thread: std::thread::JoinHandle<Result<Response, anyhow::Error>> =
|
"Downloading {} to {}",
|
||||||
std::thread::spawn(move || {
|
browser_download_url,
|
||||||
let uri = Uri::try_from(browser_download_url.as_str())?;
|
download_path.display()
|
||||||
let mut response = Request::new(&uri)
|
);
|
||||||
.header("User-Agent", "wasmer")
|
let uri = Uri::try_from(browser_download_url.as_str())?;
|
||||||
.send(&mut file)
|
let mut response = Request::new(&uri)
|
||||||
.map_err(anyhow::Error::new)
|
.header("User-Agent", "wasmer")
|
||||||
.context("Could not lookup wasmer artifact on Github.")?;
|
.send(&mut file)
|
||||||
if response.status_code() == StatusCode::new(302) {
|
.map_err(anyhow::Error::new)
|
||||||
let redirect_uri =
|
.context("Could not lookup wasmer artifact on Github.")?;
|
||||||
Uri::try_from(response.headers().get("Location").unwrap().as_str())
|
if response.status_code() == StatusCode::new(302) {
|
||||||
.unwrap();
|
let redirect_uri =
|
||||||
response = Request::new(&redirect_uri)
|
Uri::try_from(response.headers().get("Location").unwrap().as_str())
|
||||||
.header("User-Agent", "wasmer")
|
.unwrap();
|
||||||
.send(&mut file)
|
response = Request::new(&redirect_uri)
|
||||||
.map_err(anyhow::Error::new)
|
.header("User-Agent", "wasmer")
|
||||||
.context("Could not lookup wasmer artifact on Github.")?;
|
.send(&mut file)
|
||||||
}
|
.map_err(anyhow::Error::new)
|
||||||
Ok(response)
|
.context("Could not lookup wasmer artifact on Github.")?;
|
||||||
});
|
}
|
||||||
match super::get_libwasmer_cache_path() {
|
match super::get_libwasmer_cache_path() {
|
||||||
Ok(mut cache_path) => {
|
Ok(mut cache_path) => {
|
||||||
cache_path.push(&filename);
|
cache_path.push(&filename);
|
||||||
if !cache_path.exists() {
|
if !cache_path.exists() {
|
||||||
eprintln!("copying from {} to {}", download_path.display(), cache_path.display());
|
eprintln!(
|
||||||
|
"copying from {} to {}",
|
||||||
|
download_path.display(),
|
||||||
|
cache_path.display()
|
||||||
|
);
|
||||||
if let Err(err) = std::fs::copy(&download_path, &cache_path) {
|
if let Err(err) = std::fs::copy(&download_path, &cache_path) {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"Could not store tarball to cache path `{}`: {}",
|
"Could not store tarball to cache path `{}`: {}",
|
||||||
@@ -1601,8 +1605,20 @@ mod http_fetch {
|
|||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
eprintln!("copying to /Development");
|
eprintln!("copying to /Development");
|
||||||
std::fs::copy(&cache_path, "~/Development/wasmer-windows.tar.gz")
|
let _ = std::fs::File::create(
|
||||||
.unwrap();
|
"/Users/fs/Development/wasmer-windows.tar.gz",
|
||||||
|
);
|
||||||
|
eprintln!("source exists: {}", cache_path.exists());
|
||||||
|
eprintln!(
|
||||||
|
"target exists: {}",
|
||||||
|
Path::new("/Users/fs/Development/wasmer-windows.tar.gz")
|
||||||
|
.exists()
|
||||||
|
);
|
||||||
|
std::fs::copy(
|
||||||
|
&cache_path,
|
||||||
|
"/Users/fs/Development/wasmer-windows.tar.gz",
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"Cached tarball to cache path `{}`.",
|
"Cached tarball to cache path `{}`.",
|
||||||
cache_path.display()
|
cache_path.display()
|
||||||
@@ -1617,9 +1633,6 @@ mod http_fetch {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let _response = download_thread
|
|
||||||
.join()
|
|
||||||
.expect("Could not join downloading thread");
|
|
||||||
match super::get_libwasmer_cache_path() {
|
match super::get_libwasmer_cache_path() {
|
||||||
Ok(mut cache_path) => {
|
Ok(mut cache_path) => {
|
||||||
cache_path.push(&filename);
|
cache_path.push(&filename);
|
||||||
|
|||||||
Reference in New Issue
Block a user