Skip to content

Commit 4a118c1

Browse files
authored
Fix overwriting existing init files in code generator (#637)
1 parent 5f3823c commit 4a118c1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

backend/plugin/code_generator/service/gen_service.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,9 @@ async def generate(self, *, pk: int) -> None:
175175
code_folder.mkdir(parents=True, exist_ok=True)
176176

177177
init_filepath = code_folder.joinpath('__init__.py')
178-
async with aiofiles.open(init_filepath, 'w', encoding='utf-8') as f:
179-
await f.write(gen_template.init_content)
178+
if not os.path.exists(init_filepath):
179+
async with aiofiles.open(init_filepath, 'w', encoding='utf-8') as f:
180+
await f.write(gen_template.init_content)
180181

181182
# api __init__.py
182183
if 'api' in str_code_filepath:

0 commit comments

Comments
 (0)