From 2dba1025e81d52eaec256e738164365af42a87ba Mon Sep 17 00:00:00 2001 From: trivernis Date: Sun, 6 Sep 2020 17:20:21 +0200 Subject: [PATCH] Fix --no-cache to also not write to the cache dir Signed-off-by: trivernis --- Cargo.lock | 2 +- Cargo.toml | 2 +- src/utils/downloads.rs | 19 +++++++++++-------- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cf805bc..28096b6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1277,7 +1277,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "snekdown" -version = "0.27.0" +version = "0.27.1" dependencies = [ "asciimath-rs 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", "base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/Cargo.toml b/Cargo.toml index e04c5e6..a7de3db 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "snekdown" -version = "0.27.0" +version = "0.27.1" authors = ["trivernis "] edition = "2018" license-file = "LICENSE" diff --git a/src/utils/downloads.rs b/src/utils/downloads.rs index f6e7661..a659e32 100644 --- a/src/utils/downloads.rs +++ b/src/utils/downloads.rs @@ -97,14 +97,17 @@ impl PendingDownload { /// Stores the data to a cache file to retrieve it later fn store_to_cache(&self, data: &Vec) { - let cache_file = get_cached_path(PathBuf::from(&self.path)); - fs::write(&cache_file, data.clone()).unwrap_or_else(|_| { - log::warn!( - "Failed to write file to cache: {} -> {:?}", - self.path.clone(), - cache_file - ) - }); + if self.use_cache { + let cache_file = get_cached_path(PathBuf::from(&self.path)); + log::debug!("Writing to cache {} -> {:?}", self.path, cache_file); + fs::write(&cache_file, data.clone()).unwrap_or_else(|_| { + log::warn!( + "Failed to write file to cache: {} -> {:?}", + self.path, + cache_file + ) + }); + } } fn read_from_cache(&self) -> Option> {