From c7954d2294688303b0770711faef02c1064a5433 Mon Sep 17 00:00:00 2001 From: ffauzan <32434534+ffauzan@users.noreply.github.com> Date: Tue, 19 Jul 2022 06:39:29 +0700 Subject: [PATCH] Update file_helpers.rs --- src-tauri/src/file_helpers.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src-tauri/src/file_helpers.rs b/src-tauri/src/file_helpers.rs index 68c4878..db06794 100644 --- a/src-tauri/src/file_helpers.rs +++ b/src-tauri/src/file_helpers.rs @@ -138,19 +138,11 @@ pub fn write_file(path: String, contents: String) { let path_buf = std::path::PathBuf::from(&path); // Create file if it exists, otherwise just open and rewrite - let mut file = match fs::File::options().write(true).truncate(true).open(&path_buf) { + let mut file = match fs::File::create(&path_buf) { Ok(file) => file, Err(e) => { println!("Failed to open file: {}", e); - - // attempt to create file. otherwise return - match fs::File::create(&path_buf) { - Ok(file) => file, - Err(e) => { - println!("Failed to create file: {}", e); - return; - } - } + return; } };