From ec4168769e50674405316d3bc9f584fafa90f22d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matej=20Jane=C5=BEi=C4=8D?= Date: Fri, 4 Sep 2026 09:17:20 +0000 Subject: [PATCH] fix: keep existing contents in create_file --- src/lib.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index c24d234..561f014 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,6 +19,12 @@ fn safe_create_file(path: PathBuf) -> Result { OpenOptions::new().write(true).create_new(true).open(path) } +// truncate(false) keeps an existing file's contents, which is what callers creating +// an empty __init__.py want fn create_file(path: PathBuf) -> Result { - OpenOptions::new().write(true).create(true).open(path) + OpenOptions::new() + .write(true) + .create(true) + .truncate(false) + .open(path) }