use retry mechanism for fetching data
Some checks failed
CI/CD Pipeline / test (push) Failing after 1m43s

This commit is contained in:
2024-02-18 17:00:15 +01:00
parent bdc6f87efa
commit 13c734019d
2 changed files with 35 additions and 2 deletions

View File

@ -29,7 +29,7 @@ use log::info;
use crate::{
law::LawBuilder,
misc::{get_cache_dir, Error},
misc::{fetch_with_retries, get_cache_dir, Error},
};
use self::parser::Risdok;
@ -138,7 +138,7 @@ fn fetch(url: &str) -> Result<String, Error> {
Ok(data) => Ok(data),
Err(_) => {
info!("Not finding url {url} in the cache, downloading...");
let data = ureq::get(url).call()?.into_string()?;
let data = fetch_with_retries(url)?;
let path = Path::new(&expected_filename);
if let Some(parent) = path.parent() {
// Try to create the directory (and any necessary parent directories)