import os
from pathlib import Path

from folkugat_web.log import logger

DB_DIR = Path(os.getenv("DB_DIR", "/home/marc/tmp/folkugat")).resolve()
DB_FILE = DB_DIR / "folkugat.db"

logger.info(f"Using DB_DIR: {DB_DIR}")

# Files db

DB_FILES_DIR = DB_DIR / "fitxer"
DB_FILES_TEMA_DIR = DB_FILES_DIR / "tema"
DB_FILES_SESSION_DIR = DB_FILES_DIR / "sessio"
DB_FILES_SET_DIR = DB_FILES_DIR / "set"
DB_FILES_PLAYLIST_DIR = DB_FILES_DIR / "llistes"
DB_FILES_TMP_DIR = DB_FILES_DIR / "tmp"

for path in [
        DB_FILES_DIR,
        DB_FILES_TEMA_DIR,
        DB_FILES_SET_DIR,
        DB_FILES_PLAYLIST_DIR,
        DB_FILES_SET_DIR,
]:
    path.mkdir(exist_ok=True)

DB_FILES_URL = "/db/fitxer"

_MB = 1024 * 1024
FILE_MAX_SIZE = 10 * _MB
