mirror of
https://github.com/hay-kot/mealie.git
synced 2025-08-22 14:33:33 -07:00
bug: ensure diretory exists before mount sql
This commit is contained in:
parent
e548270ed0
commit
a2eef6b73d
5 changed files with 19 additions and 10 deletions
|
@ -2,7 +2,7 @@ import uvicorn
|
|||
from fastapi import FastAPI
|
||||
from fastapi.staticfiles import StaticFiles
|
||||
|
||||
import utils.startup as startup
|
||||
# import utils.startup as startup
|
||||
from app_config import PORT, PRODUCTION, WEB_PATH, docs_url, redoc_url
|
||||
from routes import (
|
||||
backup_routes,
|
||||
|
@ -16,7 +16,10 @@ from routes import (
|
|||
from utils.api_docs import generate_api_docs
|
||||
from utils.logger import logger
|
||||
|
||||
startup.pre_start()
|
||||
# startup.pre_start()
|
||||
|
||||
# if USE_SQL:
|
||||
# sql_global_init()
|
||||
|
||||
app = FastAPI(
|
||||
title="Mealie",
|
||||
|
|
|
@ -6,6 +6,11 @@ import dotenv
|
|||
CWD = Path(__file__).parent
|
||||
|
||||
|
||||
def ensure_dirs():
|
||||
for dir in REQUIRED_DIRS:
|
||||
dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
# Register ENV
|
||||
ENV = CWD.joinpath(".env")
|
||||
dotenv.load_dotenv(ENV)
|
||||
|
@ -51,6 +56,8 @@ DATABASE_TYPE = os.getenv("db_type", "sql") # mongo, tinydb
|
|||
if DATABASE_TYPE == "sql":
|
||||
USE_SQL = True
|
||||
USE_MONGO = False
|
||||
SQLITE_FILE = SQLITE_DIR.joinpath("mealie.sqlite")
|
||||
|
||||
|
||||
elif DATABASE_TYPE == "mongo":
|
||||
USE_MONGO = True
|
||||
|
@ -71,3 +78,6 @@ DB_PORT = os.getenv("db_port", 27017)
|
|||
# SFTP Email Stuff - For use Later down the line!
|
||||
SFTP_USERNAME = os.getenv("sftp_username", None)
|
||||
SFTP_PASSWORD = os.getenv("sftp_password", None)
|
||||
|
||||
|
||||
ensure_dirs()
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
from app_config import DATA_DIR, SQLITE_DIR, USE_MONGO, USE_SQL
|
||||
from app_config import SQLITE_FILE, USE_MONGO, USE_SQL
|
||||
|
||||
from db.sql.db_session import globa_init as sql_global_init
|
||||
|
||||
if USE_SQL:
|
||||
db_file = DATA_DIR.joinpath("mealie.sqlite")
|
||||
sql_global_init(db_file)
|
||||
sql_global_init(SQLITE_FILE)
|
||||
pass
|
||||
|
||||
elif USE_MONGO:
|
||||
from db.mongo.mongo_setup import global_init as mongo_global_init
|
||||
|
|
|
@ -13,7 +13,6 @@ def globa_init(db_file: Path):
|
|||
|
||||
if __factory:
|
||||
return
|
||||
|
||||
conn_str = "sqlite:///" + str(db_file.absolute())
|
||||
|
||||
engine = sa.create_engine(conn_str, echo=False)
|
||||
|
|
|
@ -7,13 +7,10 @@ CWD = Path(__file__).parent
|
|||
|
||||
|
||||
def pre_start():
|
||||
ensure_dirs()
|
||||
default_theme_init()
|
||||
|
||||
|
||||
def ensure_dirs():
|
||||
for dir in REQUIRED_DIRS:
|
||||
dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue