safety check so db folder exists

This commit is contained in:
Firq 2023-10-01 21:47:33 +02:00
parent 58c843800c
commit da222b5d11
Signed by: Firq
GPG key ID: 3ACC61C8CEC83C20

View file

@ -1,5 +1,6 @@
# pylint: disable=too-few-public-methods # pylint: disable=too-few-public-methods
import os
import dictdatabase as DDB import dictdatabase as DDB
from config.db_settings import DatabaseSettings from config.db_settings import DatabaseSettings
@ -12,6 +13,8 @@ class Database:
""" """
__instance = None __instance = None
db = DDB db = DDB
if not os.path.isdir(DatabaseSettings.DATABASE_DIRECTORY):
os.mkdir(DatabaseSettings.DATABASE_DIRECTORY)
db.config.storage_directory = DatabaseSettings.DATABASE_DIRECTORY db.config.storage_directory = DatabaseSettings.DATABASE_DIRECTORY
if not db.at("requests").exists(): if not db.at("requests").exists():
db.at("requests").create({}) db.at("requests").create({})