0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-04 01:44:26 -05:00

Fix failure message for deno upgrade (#6348)

This commit is contained in:
crowlKats 2020-06-18 03:38:52 +02:00 committed by GitHub
parent 097e42418c
commit ebf5c7b8cc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -90,14 +90,12 @@ pub async fn upgrade_command(
} }
}; };
println!( let archive_data = download_package(
"Version has been found\nDeno is upgrading to version {}", &compose_url_to_exec(&install_version)?,
&install_version client,
); &install_version,
)
let archive_data = .await?;
download_package(&compose_url_to_exec(&install_version)?, client).await?;
let old_exe_path = std::env::current_exe()?; let old_exe_path = std::env::current_exe()?;
let new_exe_path = unpack(archive_data)?; let new_exe_path = unpack(archive_data)?;
let permissions = fs::metadata(&old_exe_path)?.permissions(); let permissions = fs::metadata(&old_exe_path)?.permissions();
@ -116,15 +114,29 @@ pub async fn upgrade_command(
fn download_package( fn download_package(
url: &Url, url: &Url,
client: Client, client: Client,
version: &Version,
) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, ErrBox>>>> { ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, ErrBox>>>> {
println!("downloading {}", url); println!("downloading {}", url);
let url = url.clone(); let url = url.clone();
let version = version.clone();
let fut = async move { let fut = async move {
match fetch_once(client.clone(), &url, None).await? { match fetch_once(client.clone(), &url, None).await {
Ok(result) => {
println!(
"Version has been found\nDeno is upgrading to version {}",
&version
);
match result {
FetchOnceResult::Code(source, _) => Ok(source), FetchOnceResult::Code(source, _) => Ok(source),
FetchOnceResult::NotModified => unreachable!(), FetchOnceResult::NotModified => unreachable!(),
FetchOnceResult::Redirect(_url, _) => { FetchOnceResult::Redirect(_url, _) => {
download_package(&_url, client).await download_package(&_url, client, &version).await
}
}
}
Err(_) => {
println!("Version has not been found, aborting");
std::process::exit(1)
} }
} }
}; };