mirror of
https://github.com/stalwartlabs/mail-server.git
synced 2025-02-25 08:23:00 +08:00
Added timeouts to install script (fixes #138)
This commit is contained in:
parent
633181a80c
commit
5c1a0f7d2f
1 changed files with 15 additions and 7 deletions
|
@ -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<Path>, replacements: &[(&str, impl AsRef<str>)]) {
|
|||
}
|
||||
|
||||
fn download(url: &str) -> Vec<u8> {
|
||||
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!(
|
||||
|
|
Loading…
Reference in a new issue