Fix problems with creating temp file for pdf rendering

Signed-off-by: trivernis <trivernis@protonmail.com>
develop
trivernis 3 years ago
parent cdbfe8c195
commit 0495855d91
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -26,8 +26,13 @@ pub mod result;
/// Renders the document to pdf and returns the resulting bytes
pub fn render_to_pdf(document: Document) -> PdfRenderingResult<Vec<u8>> {
let cache = CacheStorage::new();
let mut file_path = PathBuf::from(format!("tmp-document.html"));
let mut file_path = PathBuf::from("tmp-document.html");
file_path = cache.get_file_path(&file_path);
if !file_path.parent().map(|p| p.exists()).unwrap_or(false) {
file_path = PathBuf::from(".tmp-document.html")
}
let config = document.config.clone();
let mathjax = config.lock().features.include_mathjax;

@ -35,6 +35,7 @@ impl CacheStorage {
if let Some(extension) = path.extension() {
file_name.set_extension(extension);
}
log::trace!("Cache path is {:?}", path);
return self.location.join(PathBuf::from(file_name));
}

Loading…
Cancel
Save