Fix overwriting existing init files in code generator (#637)

This commit is contained in:
yzbf
2025-05-28 20:17:18 +08:00
committed by GitHub
parent 5f3823cb6d
commit 4a118c166a
@@ -175,8 +175,9 @@ class GenService:
code_folder.mkdir(parents=True, exist_ok=True)
init_filepath = code_folder.joinpath('__init__.py')
async with aiofiles.open(init_filepath, 'w', encoding='utf-8') as f:
await f.write(gen_template.init_content)
if not os.path.exists(init_filepath):
async with aiofiles.open(init_filepath, 'w', encoding='utf-8') as f:
await f.write(gen_template.init_content)
# api __init__.py
if 'api' in str_code_filepath: