mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
🩹 检测数据库路径
This commit is contained in:
parent
be52ec2bde
commit
c0539cf1a6
@ -52,7 +52,10 @@ async def _(setting: Setting) -> Result:
|
||||
port = setting.port
|
||||
if setting.db_url:
|
||||
if setting.db_url.startswith("sqlite"):
|
||||
base_dir = Path().resolve()
|
||||
db_path = Path(setting.db_url.split(":")[-1])
|
||||
if db_path.is_absolute() and not db_path.is_relative_to(base_dir):
|
||||
return Result.fail("数据库路径不在项目根目录内。")
|
||||
db_path.parent.mkdir(parents=True, exist_ok=True)
|
||||
env_text = env_text.replace('DB_URL = ""', f'DB_URL = "{setting.db_url}"')
|
||||
if setting.username:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user