Fix --no-cache to also not write to the cache dir

Signed-off-by: trivernis <trivernis@protonmail.com>
feature/epub-rendering
trivernis 4 years ago
parent dc884890d4
commit 2dba1025e8
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

2
Cargo.lock generated

@ -1277,7 +1277,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]] [[package]]
name = "snekdown" name = "snekdown"
version = "0.27.0" version = "0.27.1"
dependencies = [ dependencies = [
"asciimath-rs 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", "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)", "base64 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)",

@ -1,6 +1,6 @@
[package] [package]
name = "snekdown" name = "snekdown"
version = "0.27.0" version = "0.27.1"
authors = ["trivernis <trivernis@protonmail.com>"] authors = ["trivernis <trivernis@protonmail.com>"]
edition = "2018" edition = "2018"
license-file = "LICENSE" license-file = "LICENSE"

@ -97,14 +97,17 @@ impl PendingDownload {
/// Stores the data to a cache file to retrieve it later /// Stores the data to a cache file to retrieve it later
fn store_to_cache(&self, data: &Vec<u8>) { fn store_to_cache(&self, data: &Vec<u8>) {
let cache_file = get_cached_path(PathBuf::from(&self.path)); if self.use_cache {
fs::write(&cache_file, data.clone()).unwrap_or_else(|_| { let cache_file = get_cached_path(PathBuf::from(&self.path));
log::warn!( log::debug!("Writing to cache {} -> {:?}", self.path, cache_file);
"Failed to write file to cache: {} -> {:?}", fs::write(&cache_file, data.clone()).unwrap_or_else(|_| {
self.path.clone(), log::warn!(
cache_file "Failed to write file to cache: {} -> {:?}",
) self.path,
}); cache_file
)
});
}
} }
fn read_from_cache(&self) -> Option<Vec<u8>> { fn read_from_cache(&self) -> Option<Vec<u8>> {

Loading…
Cancel
Save