Skip to content

Commit

Permalink
🐛 wasi: Fixed could be failed to create temp file
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanTsune committed Dec 17, 2024
1 parent 69e7426 commit 88c6cd1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 25 deletions.
32 changes: 16 additions & 16 deletions cli/src/command/commons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -590,14 +590,14 @@ where
let password = password_provider();
let output_path = output_path.as_ref();
let random = rand::random::<usize>();
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)?;

Expand Down Expand Up @@ -654,14 +654,14 @@ where
let password = password_provider();
let output_path = output_path.as_ref();
let random = rand::random::<usize>();
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)?;

Expand Down
17 changes: 8 additions & 9 deletions cli/src/command/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,14 @@ fn update_archive<Strategy: TransformStrategy>(args: UpdateCommand) -> io::Resul
let (tx, rx) = std::sync::mpsc::channel();

let random = rand::random::<usize>();
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)?;

Expand Down

0 comments on commit 88c6cd1

Please sign in to comment.