feat(restore): implement slice 4 snapshot management, diff engine, and safe restore

This commit is contained in:
soda64 committed 2026-10-09 19:19:28 +02:00
1 parent 646bd9d145
commit 8d4127de30
9 files changed
+1386 -4

No files matched your search

+37
View File
@@ -113,3 +113,40 @@ class SnapshotManifest:
stats=data.get("stats", {}),
files_sha256=data.get("files_sha256", {})
)
@dataclass
class RestorePlanItem:
rel_path: str
abs_path: str
action: str # "create", "modify", "skip"
reason: Optional[str] = None
is_sensitive_network: bool = False
source_sha256: Optional[str] = None
target_sha256: Optional[str] = None
def to_dict(self) -> Dict[str, Any]:
return asdict(self)
@dataclass
class RestorePlan:
snapshot_id: str
target_root: str
items: List[RestorePlanItem] = field(default_factory=list)
safety_snapshot_id: Optional[str] = None
requires_force: bool = True
def to_dict(self) -> Dict[str, Any]:
return {
"snapshot_id": self.snapshot_id,
"target_root": self.target_root,
"items": [item.to_dict() for item in self.items],
"safety_snapshot_id": self.safety_snapshot_id,
"requires_force": self.requires_force,
"summary": {
"create_count": sum(1 for i in self.items if i.action == "create"),
"modify_count": sum(1 for i in self.items if i.action == "modify"),
"skip_count": sum(1 for i in self.items if i.action == "skip"),
"sensitive_network_count": sum(1 for i in self.items if i.is_sensitive_network)
}
}