have this rust method in tauri
#[tauri::command]
async fn overwrite_file_content(path: String, new_content: String) -> Result<(), String> {
use std::io::Write;
let path = PathBuf::from(&path);
if path.exists() {
let mut file = match fs::OpenOptions::new().write(true).open(&path) {
Ok(file) => file,
Err(e) => return Err(format!("Failed to open file: {}", e)),
};
match file.write_all(new_content.as_bytes()) {
Ok(_) => Ok(()),
Err(e) => Err(format!("Failed to write to file: {}", e)),
}
} else {
Err("File does not exist".into())
}
}
for some reason after trying to write to any file, for example a file that ends with
- [Testing The "Impossible": 17 Questions That Changed My Life (2016)](https://tim.blog/2016/12/07/testing-the-impossible-17-questions-that-changed-my-life/)
- [The Proust Questionnaire](https://www.vanityfair.com/magazine/2000/01/proust-questionnaire)
after that rust method is called, the file will be
- [Testing The "Impossible": 17 Questions That Changed My Life (2016)](https://tim.blog/2016/12/07/testing-the-impossible-17-questions-that-changed-my-life/)
- [The Proust Questionnaire](https://www.vanityfair.com/magazine/2000/01/proust-questionnaire)
aire)
notice the aire) added.
i asked gpt-4 for a fix but solution it gave failed for me, how can I solve this? thanks ♥️