The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(backup): route read-only restore opens through read_only_db_uri
kshitijk4poor48f1bf725188
diff --git a/hermes_cli/backup.py b/hermes_cli/backup.pyindex af5b8e82597..fd04dac1192 100644--- a/hermes_cli/backup.py+++ b/hermes_cli/backup.py@@ -22,6 +22,7 @@ from hermes_constants import (display_hermes_home,)from hermes_state_dbfile import RETIRED_GENERATION_DIR_SUFFIX+from hermes_state_holders import read_only_db_urifrom hermes_cli.archive_safe import normalize_archive_partsfrom hermes_cli.backup_sqlite import _close_quietly, _safe_copy_db@@ -348,7 +349,7 @@ def _query_ro_sqlite(path: Path, fn):"""Run ``fn(conn)`` on a read-only connection to *path*; return ``(value, None)`` or ``(None, exc)``."""conn = Nonetry:- conn = sqlite3.connect(f"{path.resolve().as_uri()}?mode=ro", uri=True, timeout=1.0)+ conn = sqlite3.connect(read_only_db_uri(path), uri=True, timeout=1.0)return fn(conn), Noneexcept Exception as exc:return None, excdiff --git a/hermes_cli/backup_restore.py b/hermes_cli/backup_restore.pyindex 457c264089d..d80fc84be3a 100644--- a/hermes_cli/backup_restore.py+++ b/hermes_cli/backup_restore.py@@ -18,6 +18,7 @@ import zipfilefrom pathlib import Pathfrom typing import List, Optional, Tuple+from hermes_state_holders import read_only_db_urifrom utils import (_preserve_file_mode, _preserve_file_owner, _restore_file_mode, _restore_file_owner, atomic_replace,)@@ -116,7 +117,7 @@ def _safe_restore_db(src: Path, dst: Path) -> bool:dst_conn.execute("PRAGMA wal_checkpoint(TRUNCATE)")except Exception:pass- src_conn = sqlite3.connect(f"{src.resolve().as_uri()}?mode=ro", uri=True)+ src_conn = sqlite3.connect(read_only_db_uri(src), uri=True)try:src_conn.backup(dst_conn)finally:@@ -390,7 +391,7 @@ def _count_session_rows(path: Path) -> Optional[Tuple[int, int]]:if not path.is_file():return Nonetry:- conn = sqlite3.connect(f"{path.resolve().as_uri()}?mode=ro", uri=True)+ conn = sqlite3.connect(read_only_db_uri(path), uri=True)except sqlite3.Error:return Nonetry: