fix: use directory config mount for casaos
This commit is contained in:
@@ -1,12 +1,16 @@
|
||||
import json
|
||||
import aiofiles
|
||||
import os
|
||||
from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
CONFIG_PATH = Path("config.json")
|
||||
import aiofiles
|
||||
|
||||
CONFIG_PATH = Path(os.getenv("CONFIG_PATH", "/app/data/config.json"))
|
||||
|
||||
|
||||
async def load_config() -> dict:
|
||||
if CONFIG_PATH.is_dir():
|
||||
return {}
|
||||
if not CONFIG_PATH.exists():
|
||||
return {}
|
||||
async with aiofiles.open(CONFIG_PATH, "r") as f:
|
||||
@@ -15,6 +19,7 @@ async def load_config() -> dict:
|
||||
|
||||
|
||||
async def save_config(config: dict) -> None:
|
||||
CONFIG_PATH.parent.mkdir(parents=True, exist_ok=True)
|
||||
async with aiofiles.open(CONFIG_PATH, "w") as f:
|
||||
await f.write(json.dumps(config, indent=2))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user