From 5c1a0f7d2f546d2a16fd0ec3aa7af64dbdda7e68 Mon Sep 17 00:00:00 2001 From: mdecimus Date: Tue, 9 Jan 2024 18:16:28 +0100 Subject: [PATCH] Added timeouts to install script (fixes #138) --- crates/install/src/main.rs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/crates/install/src/main.rs b/crates/install/src/main.rs index 3932af8d..07d4f591 100644 --- a/crates/install/src/main.rs +++ b/crates/install/src/main.rs @@ -27,6 +27,7 @@ use std::{ io::Cursor, path::{Path, PathBuf}, process::exit, + time::Duration, }; use base64::{engine::general_purpose, Engine}; @@ -693,13 +694,20 @@ fn sed(path: impl AsRef, replacements: &[(&str, impl AsRef)]) { } fn download(url: &str) -> Vec { - match reqwest::blocking::get(url).and_then(|r| { - if r.status().is_success() { - r.bytes().map(Ok) - } else { - Ok(Err(r)) - } - }) { + match reqwest::blocking::Client::builder() + .connect_timeout(Duration::from_secs(60)) + .timeout(Duration::from_secs(60)) + .build() + .unwrap_or_default() + .get(url) + .send() + .and_then(|r| { + if r.status().is_success() { + r.bytes().map(Ok) + } else { + Ok(Err(r)) + } + }) { Ok(Ok(bytes)) => bytes.to_vec(), Ok(Err(response)) => { eprintln!(