(path: Path, data: dict)
| 369 | |
| 370 | |
| 371 | def _snapshot_from_journal(path: Path, data: dict) -> MutationSnapshot: |
| 372 | snapshot = MutationSnapshot( |
| 373 | kb_dir=Path(data["kb_dir"]), |
| 374 | backup_dir=Path(data["backup_dir"]), |
| 375 | journal_path=path, |
| 376 | operation=data.get("operation", "mutation"), |
| 377 | details=data.get("details") or {}, |
| 378 | ) |
| 379 | snapshot.entries = { |
| 380 | Path(item["target"]): Path(item["backup"]) if item.get("backup") else None |
| 381 | for item in data.get("entries", []) |
| 382 | } |
| 383 | snapshot.attempts = int(data.get("attempts", 0) or 0) |
| 384 | return snapshot |
| 385 | |
| 386 | |
| 387 | def recover_pending_journals(kb_dir: Path) -> list[str]: |
no test coverage detected