Remove threading when dowloading release to prevent unexpected failure

This commit is contained in:
Felix Schütt
2022-11-14 15:52:05 +01:00
parent ddf4b33d0b
commit 18765cda89

View File

@@ -1567,9 +1567,11 @@ mod http_fetch {
let download_tempdir = tempdir::TempDir::new("wasmer-download")?;
let download_path = download_tempdir.path().to_path_buf().join(&filename);
let mut file = std::fs::File::create(&download_path)?;
println!("Downloading {} to {}", browser_download_url, download_path.display());
let download_thread: std::thread::JoinHandle<Result<Response, anyhow::Error>> =
std::thread::spawn(move || {
println!(
"Downloading {} to {}",
browser_download_url,
download_path.display()
);
let uri = Uri::try_from(browser_download_url.as_str())?;
let mut response = Request::new(&uri)
.header("User-Agent", "wasmer")
@@ -1586,13 +1588,15 @@ mod http_fetch {
.map_err(anyhow::Error::new)
.context("Could not lookup wasmer artifact on Github.")?;
}
Ok(response)
});
match super::get_libwasmer_cache_path() {
Ok(mut cache_path) => {
cache_path.push(&filename);
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) {
eprintln!(
"Could not store tarball to cache path `{}`: {}",
@@ -1601,7 +1605,19 @@ mod http_fetch {
);
} else {
eprintln!("copying to /Development");
std::fs::copy(&cache_path, "~/Development/wasmer-windows.tar.gz")
let _ = std::fs::File::create(
"/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!(
"Cached tarball to cache path `{}`.",
@@ -1617,9 +1633,6 @@ mod http_fetch {
);
}
}
let _response = download_thread
.join()
.expect("Could not join downloading thread");
match super::get_libwasmer_cache_path() {
Ok(mut cache_path) => {
cache_path.push(&filename);