Restore code from a snapshot. Returns True on success.
(self, snapshot_id: str)
| 67 | # -- rollback ------------------------------------------------------ |
| 68 | |
| 69 | def rollback(self, snapshot_id: str) -> bool: |
| 70 | """Restore code from a snapshot. Returns True on success.""" |
| 71 | zip_path = self.backup_dir / f"{snapshot_id}.zip" |
| 72 | if not zip_path.exists(): |
| 73 | return False |
| 74 | |
| 75 | # Remove current files (except .code_backups) |
| 76 | for fp in list(self.code_dir.rglob("*")): |
| 77 | if fp.is_file() and ".code_backups" not in fp.parts: |
| 78 | fp.unlink() |
| 79 | |
| 80 | # Extract |
| 81 | with zipfile.ZipFile(zip_path, "r") as zf: |
| 82 | zf.extractall(self.code_dir) |
| 83 | return True |
| 84 | |
| 85 | def rollback_latest(self) -> str | None: |
| 86 | """Rollback to the most recent snapshot. Returns snapshot id or None.""" |
no outgoing calls
no test coverage detected