mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2024-12-12 09:51:23 +01:00
Fixed issue when the iconlist is smaller then 5
When the iconlist was smaller then 5 items, it would cause a panic. Solved by using .truncate() on the iconlist.
This commit is contained in:
parent
574b040142
commit
9026cc8d42
1 changed files with 4 additions and 5 deletions
|
@ -265,7 +265,7 @@ fn get_icon_priority(href: &str, sizes: &str) -> u8 {
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
/// * `sizes` - The size of the icon if available as a <width>x<height> value like 32x32.
|
/// * `sizes` - The size of the icon if available as a <width>x<height> value like 32x32.
|
||||||
///
|
///
|
||||||
/// # Example
|
/// # Example
|
||||||
/// ```
|
/// ```
|
||||||
/// let (width, height) = parse_sizes("64x64"); // (64, 64)
|
/// let (width, height) = parse_sizes("64x64"); // (64, 64)
|
||||||
|
@ -296,9 +296,9 @@ fn download_icon(domain: &str) -> Result<Vec<u8>, Error> {
|
||||||
|
|
||||||
let mut buffer = Vec::new();
|
let mut buffer = Vec::new();
|
||||||
|
|
||||||
let mut attempts = 0;
|
iconlist.truncate(5);
|
||||||
while attempts < 5 {
|
for icon in iconlist {
|
||||||
let url = &iconlist.remove(0).href;
|
let url = icon.href;
|
||||||
info!("Downloading icon for {} via {}...", domain, url);
|
info!("Downloading icon for {} via {}...", domain, url);
|
||||||
match get_page_with_cookies(&url, &cookie_str) {
|
match get_page_with_cookies(&url, &cookie_str) {
|
||||||
Ok(mut res) => {
|
Ok(mut res) => {
|
||||||
|
@ -308,7 +308,6 @@ fn download_icon(domain: &str) -> Result<Vec<u8>, Error> {
|
||||||
},
|
},
|
||||||
Err(_) => info!("Download failed for {}", url),
|
Err(_) => info!("Download failed for {}", url),
|
||||||
};
|
};
|
||||||
attempts += 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if buffer.is_empty() {
|
if buffer.is_empty() {
|
||||||
|
|
Loading…
Reference in a new issue