Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 0 additions & 44 deletions src/ocbs/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,20 +192,6 @@ def _init_db(self):
"""
)

def _ensure_serve_records_table(self, conn: sqlite3.Connection):
"""Create serve_records if it is missing in an older or partial DB."""

conn.execute(
"""
CREATE TABLE IF NOT EXISTS serve_records (
checkpoint_id TEXT PRIMARY KEY,
backup_id TEXT,
reason TEXT,
timestamp TEXT,
FOREIGN KEY (backup_id) REFERENCES backups(backup_id)
)
"""
)

def _resolve_restore_path(self, file_path: str, target_dir: Path) -> Path:
"""Resolve a stored backup path into a safe destination under target_dir."""
Expand Down Expand Up @@ -709,36 +695,6 @@ def create_checkpoint(self, reason: str = "") -> str:

return checkpoint_id

def get_checkpoint_serves(self, checkpoint_id: Optional[str] = None) -> list[dict]:
"""Return recorded checkpoint serve entries."""

with sqlite3.connect(self.db_path, timeout=30) as conn:
conn.execute("PRAGMA journal_mode=WAL")
conn.execute("PRAGMA busy_timeout=30000")
self._ensure_serve_records_table(conn)

if checkpoint_id:
cursor = conn.execute(
"""SELECT checkpoint_id, backup_id, reason, timestamp
FROM serve_records WHERE checkpoint_id = ?
ORDER BY timestamp DESC""",
(checkpoint_id,),
)
else:
cursor = conn.execute(
"""SELECT checkpoint_id, backup_id, reason, timestamp
FROM serve_records ORDER BY timestamp DESC"""
)

return [
{
"checkpoint_id": row[0],
"backup_id": row[1],
"reason": row[2],
"timestamp": row[3],
}
for row in cursor.fetchall()
]

def restore(
self,
Expand Down
2 changes: 1 addition & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def test_get_checkpoint_serves_handles_missing_table(self, ocbs):
with sqlite3.connect(ocbs.db_path) as conn:
conn.execute("DROP TABLE serve_records")

assert ocbs.get_checkpoint_serves() == []
assert ocbs.get_checkpoint_serves("fake_id") == []


class TestBackupScope:
Expand Down