Consolidate setup persistence into bootstrap metadata and runtime DB
This commit is contained in:
@@ -82,22 +82,11 @@ async def run_setup(
|
||||
# Run in a thread executor so the blocking bcrypt operation does not stall
|
||||
# the asyncio event loop.
|
||||
password_bytes = master_password.encode()
|
||||
loop = asyncio.get_running_loop()
|
||||
hashed: str = await run_blocking(
|
||||
lambda: bcrypt.hashpw(password_bytes, bcrypt.gensalt()).decode()
|
||||
)
|
||||
|
||||
await settings_repo.set_setting(db, _KEY_PASSWORD_HASH, hashed)
|
||||
await settings_repo.set_setting(db, _KEY_DATABASE_PATH, database_path)
|
||||
await settings_repo.set_setting(db, _KEY_FAIL2BAN_SOCKET, fail2ban_socket)
|
||||
await settings_repo.set_setting(db, _KEY_TIMEZONE, timezone)
|
||||
await settings_repo.set_setting(
|
||||
db, _KEY_SESSION_DURATION, str(session_duration_minutes)
|
||||
)
|
||||
# Initialize map color thresholds with default values
|
||||
await settings_repo.set_setting(db, _KEY_MAP_COLOR_THRESHOLD_HIGH, "100")
|
||||
await settings_repo.set_setting(db, _KEY_MAP_COLOR_THRESHOLD_MEDIUM, "50")
|
||||
await settings_repo.set_setting(db, _KEY_MAP_COLOR_THRESHOLD_LOW, "20")
|
||||
|
||||
runtime_initialized = await _ensure_database_initialized(database_path)
|
||||
|
||||
@@ -138,6 +127,11 @@ async def get_password_hash(db: aiosqlite.Connection) -> str | None:
|
||||
return await util_get_password_hash(db)
|
||||
|
||||
|
||||
async def get_runtime_database_path(db: aiosqlite.Connection) -> str | None:
|
||||
"""Return the runtime database path persisted during initial setup."""
|
||||
return await settings_repo.get_setting(db, _KEY_DATABASE_PATH)
|
||||
|
||||
|
||||
async def get_persisted_runtime_settings(db: aiosqlite.Connection) -> dict[str, str | int]:
|
||||
"""Return runtime configuration values persisted during initial setup."""
|
||||
runtime_settings: dict[str, str | int] = {}
|
||||
|
||||
Reference in New Issue
Block a user