upgrade deps
This commit is contained in:
13
src/misc.rs
13
src/misc.rs
@ -136,18 +136,23 @@ fn delete_all_in_dir<P: AsRef<Path>>(dir_path: P) -> std::io::Result<()> {
|
||||
|
||||
pub(crate) fn fetch_with_retries(url: &str) -> Result<String, Error> {
|
||||
let mut attempts = 0;
|
||||
let max_attempts = 100;
|
||||
let max_attempts = 20;
|
||||
|
||||
loop {
|
||||
match ureq::get(url).call() {
|
||||
Ok(response) => {
|
||||
Ok(mut response) => {
|
||||
// If the request is successful, return the response body
|
||||
match response.into_string() {
|
||||
match response.body_mut().read_to_string() {
|
||||
Ok(d) => return Ok(d),
|
||||
Err(e) => return Err(e.into()),
|
||||
}
|
||||
}
|
||||
Err(ureq::Error::Transport(_)) => {
|
||||
Err(ureq::Error::Protocol(_))
|
||||
| Err(ureq::Error::Io(_))
|
||||
| Err(ureq::Error::HostNotFound)
|
||||
| Err(ureq::Error::RedirectFailed)
|
||||
| Err(ureq::Error::ConnectionFailed)
|
||||
| Err(ureq::Error::Timeout(_)) => {
|
||||
// Increment the attempt counter
|
||||
attempts += 1;
|
||||
|
||||
|
@ -163,8 +163,9 @@ fn fetch_page(typ: &Typ, overview_id: usize, fassung: &str, page: usize) -> Resu
|
||||
}
|
||||
|
||||
let data = ureq::post(&format!("https://data.bka.gv.at/ris/api/v2.6/{path}"))
|
||||
.send_form(&form_params)?
|
||||
.into_string()?;
|
||||
.send_form(form_params)?
|
||||
.body_mut()
|
||||
.read_to_string()?;
|
||||
|
||||
let path = Path::new(&expected_filename);
|
||||
if let Some(parent) = path.parent() {
|
||||
|
Reference in New Issue
Block a user