mirror of
https://github.com/DrizzleTime/Foxel.git
synced 2026-09-05 15:47:00 +08:00
feat: ensure data/db directory exists during app startup
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
from services.config import VERSION, ConfigCenter
|
from services.config import VERSION, ConfigCenter
|
||||||
from services.adapters.registry import runtime_registry
|
from services.adapters.registry import runtime_registry
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
@@ -15,6 +16,7 @@ load_dotenv()
|
|||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
async def lifespan(app: FastAPI):
|
async def lifespan(app: FastAPI):
|
||||||
|
os.makedirs("data/db", exist_ok=True)
|
||||||
await init_db()
|
await init_db()
|
||||||
await runtime_registry.refresh()
|
await runtime_registry.refresh()
|
||||||
await ConfigCenter.set("APP_VERSION", VERSION)
|
await ConfigCenter.set("APP_VERSION", VERSION)
|
||||||
@@ -29,7 +31,7 @@ async def lifespan(app: FastAPI):
|
|||||||
def create_app() -> FastAPI:
|
def create_app() -> FastAPI:
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
title="Foxel",
|
title="Foxel",
|
||||||
description="AList-like virtual storage aggregator",
|
description="A highly extensible private cloud storage solution for individuals and teams",
|
||||||
lifespan=lifespan,
|
lifespan=lifespan,
|
||||||
)
|
)
|
||||||
include_routers(app)
|
include_routers(app)
|
||||||
|
|||||||
Reference in New Issue
Block a user