chore: use ".presenterm" as prefix for tmp files (#306)

This commit is contained in:
Matias Fontanini 2024-07-27 05:50:08 -07:00 committed by GitHub
commit e2000e6a9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -21,7 +21,6 @@ use std::{
sync::{Arc, Condvar, Mutex}, sync::{Arc, Condvar, Mutex},
thread, thread,
}; };
use tempfile::tempdir_in;
const DEFAULT_HORIZONTAL_MARGIN: u16 = 5; const DEFAULT_HORIZONTAL_MARGIN: u16 = 5;
const DEFAULT_VERTICAL_MARGIN: u16 = 7; const DEFAULT_VERTICAL_MARGIN: u16 = 7;
@ -198,7 +197,7 @@ impl Worker {
if let Some(image) = self.state.lock().unwrap().cache.get(&snippet).cloned() { if let Some(image) = self.state.lock().unwrap().cache.get(&snippet).cloned() {
return Ok(image); return Ok(image);
} }
let workdir = tempdir_in(&self.shared.root_dir)?; let workdir = tempfile::Builder::default().prefix(".presenterm").tempdir()?;
let output_path = workdir.path().join("output.png"); let output_path = workdir.path().join("output.png");
let input_path = workdir.path().join("input.mmd"); let input_path = workdir.path().join("input.mmd");
fs::write(&input_path, input)?; fs::write(&input_path, input)?;
@ -226,7 +225,7 @@ impl Worker {
input: &str, input: &str,
style: &TypstStyle, style: &TypstStyle,
) -> Result<Image, ThirdPartyRenderError> { ) -> Result<Image, ThirdPartyRenderError> {
let workdir = tempdir_in(&self.shared.root_dir)?; let workdir = tempfile::Builder::default().prefix(".presenterm").tempdir_in(&self.shared.root_dir)?;
let mut typst_input = Self::generate_page_header(style)?; let mut typst_input = Self::generate_page_header(style)?;
typst_input.push_str(input); typst_input.push_str(input);