Merge pull request 'database creation fixes' (#9) from v2 into main
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
Reviewed-on: #9
This commit is contained in:
5
db.py
5
db.py
@@ -10,10 +10,9 @@ DATABASE_URL = os.getenv("DATABASE_URL", "sqlite+aiosqlite:///bot.db")
|
||||
if DATABASE_URL.startswith("sqlite+aiosqlite:///"):
|
||||
db_path = DATABASE_URL.replace("sqlite+aiosqlite:///", "")
|
||||
abs_db_path = os.path.abspath(db_path)
|
||||
# Проверяем, что путь содержит директорию
|
||||
db_dir = os.path.dirname(abs_db_path)
|
||||
# Если путь содержит директорию, создаём её
|
||||
if db_dir and db_dir != os.path.abspath("") and not os.path.exists(db_dir):
|
||||
# Создаём директорию только если она не равна текущей ('.') и не пустая
|
||||
if db_dir and db_dir != os.path.abspath("") and db_dir != '.' and not os.path.exists(db_dir):
|
||||
os.makedirs(db_dir, exist_ok=True)
|
||||
# Если по этому пути уже есть папка, удаляем её и создаём файл
|
||||
if os.path.isdir(abs_db_path):
|
||||
|
||||
Reference in New Issue
Block a user