|
@ -1,6 +1,6 @@ |
|
|
use std::{ |
|
|
use std::{ |
|
|
collections::HashMap, |
|
|
collections::HashMap, |
|
|
fs::{create_dir_all, remove_file, symlink_metadata, File}, |
|
|
fs::{remove_file, symlink_metadata, File}, |
|
|
io::prelude::*, |
|
|
io::prelude::*, |
|
|
net::{IpAddr, ToSocketAddrs}, |
|
|
net::{IpAddr, ToSocketAddrs}, |
|
|
sync::{Arc, RwLock}, |
|
|
sync::{Arc, RwLock}, |
|
@ -14,7 +14,7 @@ use rocket::{http::ContentType, response::Content, Route}; |
|
|
|
|
|
|
|
|
use crate::{ |
|
|
use crate::{ |
|
|
error::Error, |
|
|
error::Error, |
|
|
util::{get_reqwest_client_builder, Cached}, |
|
|
util::{get_reqwest_client_builder, write_file, Cached}, |
|
|
CONFIG, |
|
|
CONFIG, |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
@ -705,13 +705,8 @@ fn download_icon(domain: &str) -> Result<(Vec<u8>, Option<&str>), Error> { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
fn save_icon(path: &str, icon: &[u8]) { |
|
|
fn save_icon(path: &str, icon: &[u8]) { |
|
|
match File::create(path) { |
|
|
match write_file(path, icon) { |
|
|
Ok(mut f) => { |
|
|
Ok(_) => (), |
|
|
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) => { |
|
|
Err(e) => { |
|
|
warn!("Icon save error: {:?}", e); |
|
|
warn!("Icon save error: {:?}", e); |
|
|
} |
|
|
} |
|
|