fix: enforce absolute paths for state and database files

This commit is contained in:
2026-04-07 23:21:16 -04:00
parent eb4be44c9a
commit a9c7ddec2b
45 changed files with 212 additions and 3 deletions

View File

@@ -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:

View File

@@ -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: