diff --git a/cli/src/command/commons.rs b/cli/src/command/commons.rs index 003edce9..c28eaa8e 100644 --- a/cli/src/command/commons.rs +++ b/cli/src/command/commons.rs @@ -590,14 +590,14 @@ where let password = password_provider(); let output_path = output_path.as_ref(); let random = rand::random::(); - let temp_path = temp_dir() - .unwrap_or_else(|| { - output_path - .parent() - .map(PathBuf::from) - .unwrap_or_else(|| PathBuf::from(".")) - }) - .join(format!("{}.pna.tmp", random)); + let temp_dir_path = temp_dir().unwrap_or_else(|| { + output_path + .parent() + .map(PathBuf::from) + .unwrap_or_else(|| PathBuf::from(".")) + }); + fs::create_dir_all(&temp_dir_path)?; + let temp_path = temp_dir_path.join(format!("{}.pna.tmp", random)); let outfile = fs::File::create(&temp_path)?; let mut out_archive = Archive::write_header(outfile)?; @@ -654,14 +654,14 @@ where let password = password_provider(); let output_path = output_path.as_ref(); let random = rand::random::(); - let temp_path = temp_dir() - .unwrap_or_else(|| { - output_path - .parent() - .map(PathBuf::from) - .unwrap_or_else(|| PathBuf::from(".")) - }) - .join(format!("{}.pna.tmp", random)); + let temp_dir_path = temp_dir().unwrap_or_else(|| { + output_path + .parent() + .map(PathBuf::from) + .unwrap_or_else(|| PathBuf::from(".")) + }); + fs::create_dir_all(&temp_dir_path)?; + let temp_path = temp_dir_path.join(format!("{}.pna.tmp", random)); let outfile = fs::File::create(&temp_path)?; let mut out_archive = Archive::write_header(outfile)?; diff --git a/cli/src/command/update.rs b/cli/src/command/update.rs index 55a6c702..fbbbef3e 100644 --- a/cli/src/command/update.rs +++ b/cli/src/command/update.rs @@ -199,15 +199,14 @@ fn update_archive(args: UpdateCommand) -> io::Resul let (tx, rx) = std::sync::mpsc::channel(); let random = rand::random::(); - let outfile_path = temp_dir() - .unwrap_or_else(|| { - archive_path - .parent() - .map(PathBuf::from) - .unwrap_or_else(|| PathBuf::from(".")) - }) - .join(format!("{}.pna.tmp", random)); - + let temp_dir_path = temp_dir().unwrap_or_else(|| { + archive_path + .parent() + .map(PathBuf::from) + .unwrap_or_else(|| PathBuf::from(".")) + }); + fs::create_dir_all(&temp_dir_path)?; + let outfile_path = temp_dir_path.join(format!("{}.pna.tmp", random)); let outfile = fs::File::create(&outfile_path)?; let mut out_archive = Archive::write_header(outfile)?;