fix: truncate file when not appending in writeFile, closes #7973 (#7982)

* Fix https://github.com/tauri-apps/tauri/issues/7973

* Fix https://github.com/tauri-apps/tauri/issues/7973

* Fix https://github.com/tauri-apps/tauri/issues/7973
This commit is contained in:
Ziyang Hu 2023-10-09 08:22:54 -05:00 committed by GitHub
parent 1241014a46
commit 21cdbb41a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 0 deletions

View File

@ -0,0 +1,5 @@
---
"tauri": 'patch:bug'
---
Set the correct `truncate` option on `OpenOptions` so that `write_file` can completely overwrite existing files.

View File

@ -188,6 +188,7 @@ impl Cmd {
.append(append)
.write(true)
.create(true)
.truncate(!append)
.open(&resolved_path)
.with_context(|| format!("path: {}", resolved_path.display()))
.map_err(Into::into)