Skip to content

Commit

Permalink
fix: truncate file when not appending in writeFile, closes #7973 (#…
Browse files Browse the repository at this point in the history
…7982)

* Fix #7973

* Fix #7973

* Fix #7973
  • Loading branch information
zh217 authored Oct 9, 2023
1 parent 1241014 commit 21cdbb4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changes/fix-incomplete-writeFile.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"tauri": 'patch:bug'
---

Set the correct `truncate` option on `OpenOptions` so that `write_file` can completely overwrite existing files.
1 change: 1 addition & 0 deletions core/tauri/src/endpoints/file_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 21cdbb4

Please sign in to comment.