You've already forked AstralRinth
forked from didirus/AstralRinth
fix failed fetches caching in app state
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
<input
|
<input
|
||||||
v-model="searchFilter"
|
v-model="searchFilter"
|
||||||
type="text"
|
type="text"
|
||||||
:placeholder="`Search content...`"
|
:placeholder="`Search ${filteredProjects.length} project${filteredProjects.length === 1 ? '' : 's'}...`"
|
||||||
class="text-input search-input"
|
class="text-input search-input"
|
||||||
autocomplete="off"
|
autocomplete="off"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -112,6 +112,19 @@ pub async fn fetch_advanced(
|
|||||||
let result = req.send().await;
|
let result = req.send().await;
|
||||||
match result {
|
match result {
|
||||||
Ok(x) => {
|
Ok(x) => {
|
||||||
|
if x.status().is_server_error() {
|
||||||
|
if attempt <= FETCH_ATTEMPTS {
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
return Err(crate::Error::from(
|
||||||
|
crate::ErrorKind::OtherError(
|
||||||
|
"Server error when fetching content"
|
||||||
|
.to_string(),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let bytes = if let Some((bar, total)) = &loading_bar {
|
let bytes = if let Some((bar, total)) = &loading_bar {
|
||||||
let length = x.content_length();
|
let length = x.content_length();
|
||||||
if let Some(total_size) = length {
|
if let Some(total_size) = length {
|
||||||
@@ -145,7 +158,7 @@ pub async fn fetch_advanced(
|
|||||||
if let Some(sha1) = sha1 {
|
if let Some(sha1) = sha1 {
|
||||||
let hash = sha1_async(bytes.clone()).await?;
|
let hash = sha1_async(bytes.clone()).await?;
|
||||||
if &*hash != sha1 {
|
if &*hash != sha1 {
|
||||||
if attempt <= 3 {
|
if attempt <= FETCH_ATTEMPTS {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
return Err(crate::ErrorKind::HashError(
|
return Err(crate::ErrorKind::HashError(
|
||||||
@@ -159,13 +172,13 @@ pub async fn fetch_advanced(
|
|||||||
|
|
||||||
tracing::trace!("Done downloading URL {url}");
|
tracing::trace!("Done downloading URL {url}");
|
||||||
return Ok(bytes);
|
return Ok(bytes);
|
||||||
} else if attempt <= 3 {
|
} else if attempt <= FETCH_ATTEMPTS {
|
||||||
continue;
|
continue;
|
||||||
} else if let Err(err) = bytes {
|
} else if let Err(err) = bytes {
|
||||||
return Err(err.into());
|
return Err(err.into());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_) if attempt <= 3 => continue,
|
Err(_) if attempt <= FETCH_ATTEMPTS => continue,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return Err(err.into());
|
return Err(err.into());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user