mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
Add env variable to make temp directory configurable (#153)
This commit is contained in:
parent
481f35d232
commit
fcbcd175e1
1 changed files with 3 additions and 1 deletions
|
|
@ -24,10 +24,12 @@ pub fn has_ffmpeg() -> bool {
|
|||
/// e.g. remove them in a case of ctrl-c. Having one function also good to prevent mistakes like
|
||||
/// setting the wrong prefix if done manually.
|
||||
pub fn tempfile<S: AsRef<str>>(suffix: S) -> io::Result<NamedTempFile> {
|
||||
let tmp_dir = env::var("CRUNCHY_CLI_TEMP_DIR").map_or(env::temp_dir(), |d| PathBuf::from(d));
|
||||
|
||||
let tempfile = Builder::default()
|
||||
.prefix(".crunchy-cli_")
|
||||
.suffix(suffix.as_ref())
|
||||
.tempfile_in(&env::temp_dir())?;
|
||||
.tempfile_in(tmp_dir)?;
|
||||
debug!(
|
||||
"Created temporary file: {}",
|
||||
tempfile.path().to_string_lossy()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue