diff --git a/src/cache.rs b/src/cache.rs index 1198647..40c28db 100644 --- a/src/cache.rs +++ b/src/cache.rs @@ -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,