fix: enforce absolute paths for state and database files
This commit is contained in:
@@ -11,7 +11,9 @@ from pydantic import BaseModel, field_validator
|
||||
|
||||
from decnet.distros import random_hostname as _random_hostname
|
||||
|
||||
STATE_FILE = Path("decnet-state.json")
|
||||
# Calculate absolute path to the project root (where the config file resides)
|
||||
_ROOT: Path = Path(__file__).parent.parent.absolute()
|
||||
STATE_FILE: Path = _ROOT / "decnet-state.json"
|
||||
|
||||
|
||||
def random_hostname(distro_slug: str = "debian") -> str:
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import aiosqlite
|
||||
from typing import Any, Optional
|
||||
from decnet.web.repository import BaseRepository
|
||||
from decnet.config import load_state
|
||||
from decnet.config import load_state, _ROOT
|
||||
|
||||
|
||||
class SQLiteRepository(BaseRepository):
|
||||
"""SQLite implementation of the DECNET web repository."""
|
||||
|
||||
def __init__(self, db_path: str = "decnet.db") -> None:
|
||||
def __init__(self, db_path: str = str(_ROOT / "decnet.db")) -> None:
|
||||
self.db_path: str = db_path
|
||||
|
||||
async def initialize(self) -> None:
|
||||
|
||||
Reference in New Issue
Block a user