From eeb06337ee0495cf17d361fd33a956c75c4ad8ee Mon Sep 17 00:00:00 2001 From: Maybe Waffle Date: Mon, 5 Dec 2022 19:24:49 +0400 Subject: [PATCH] fix codegen (truncate files) --- crates/teloxide-core/src/codegen.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/crates/teloxide-core/src/codegen.rs b/crates/teloxide-core/src/codegen.rs index 4c71c165..7640ba36 100644 --- a/crates/teloxide-core/src/codegen.rs +++ b/crates/teloxide-core/src/codegen.rs @@ -79,7 +79,14 @@ pub fn ensure_files_contents<'a>( let mut err_count = 0; for (path, contents) in files_and_contents { - let mut file = fs::File::options().read(true).write(true).create(true).open(path).unwrap(); + let mut file = fs::File::options() + .read(true) + .write(true) + .create(true) + .truncate(true) + .append(false) + .open(path) + .unwrap(); let mut old_contents = String::with_capacity(contents.len()); file.read_to_string(&mut old_contents).unwrap();