stop it from redownloading already cached files (or pages but i guess you could use the function for anything)
This commit is contained in:
parent
90a305f55f
commit
ce75fe6572
|
@ -1,9 +1,13 @@
|
|||
use std::{fs, process};
|
||||
use std::{fs, process, path::Path};
|
||||
|
||||
pub async fn download_image(cache_path: &str, image_url: String, file_name: String) {
|
||||
let replaced = cache_path.replace('~', &crate::get_home()[..]); // replace ~ with $HOME
|
||||
crate::ensure_exists(&replaced);
|
||||
|
||||
if Path::new(&format!("{cache_path}/{file_name}")).exists() {
|
||||
return
|
||||
}
|
||||
|
||||
let image = match reqwest::get(image_url).await {
|
||||
Ok(image) => match image.bytes().await {
|
||||
Ok(bytes) => bytes,
|
||||
|
|
Loading…
Reference in New Issue