|
|
@ -112,7 +112,9 @@ fn get_icon(domain: &str) -> Vec<u8> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Err(e) => {
|
|
|
|
Err(e) => {
|
|
|
|
error!("Error downloading icon: {:?}", e);
|
|
|
|
error!("Error downloading icon: {:?}", e);
|
|
|
|
mark_negcache(&path);
|
|
|
|
let miss_indicator = path + ".miss";
|
|
|
|
|
|
|
|
let empty_icon = Vec::new();
|
|
|
|
|
|
|
|
save_icon(&miss_indicator, &empty_icon);
|
|
|
|
FALLBACK_ICON.to_vec()
|
|
|
|
FALLBACK_ICON.to_vec()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -168,11 +170,6 @@ fn icon_is_negcached(path: &str) -> bool {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn mark_negcache(path: &str) {
|
|
|
|
|
|
|
|
let miss_indicator = path.to_owned() + ".miss";
|
|
|
|
|
|
|
|
File::create(&miss_indicator).expect("Error creating negative cache marker");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fn icon_is_expired(path: &str) -> bool {
|
|
|
|
fn icon_is_expired(path: &str) -> bool {
|
|
|
|
let expired = file_is_expired(path, CONFIG.icon_cache_ttl());
|
|
|
|
let expired = file_is_expired(path, CONFIG.icon_cache_ttl());
|
|
|
|
expired.unwrap_or(true)
|
|
|
|
expired.unwrap_or(true)
|
|
|
@ -395,11 +392,17 @@ fn download_icon(domain: &str) -> Result<Vec<u8>, Error> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn save_icon(path: &str, icon: &[u8]) {
|
|
|
|
fn save_icon(path: &str, icon: &[u8]) {
|
|
|
|
create_dir_all(&CONFIG.icon_cache_folder()).expect("Error creating icon cache");
|
|
|
|
match File::create(path) {
|
|
|
|
|
|
|
|
Ok(mut f) => {
|
|
|
|
if let Ok(mut f) = File::create(path) {
|
|
|
|
f.write_all(icon).expect("Error writing icon file");
|
|
|
|
f.write_all(icon).expect("Error writing icon file");
|
|
|
|
}
|
|
|
|
};
|
|
|
|
Err(ref e) if e.kind() == std::io::ErrorKind::NotFound => {
|
|
|
|
|
|
|
|
create_dir_all(&CONFIG.icon_cache_folder()).expect("Error creating icon cache");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
Err(e) => {
|
|
|
|
|
|
|
|
info!("Icon save error: {:?}", e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn _header_map() -> HeaderMap {
|
|
|
|
fn _header_map() -> HeaderMap {
|
|
|
|