fix(archive): preserve prepared sessions across restarts
This commit is contained in:
@@ -175,6 +175,42 @@ class RecordedMediaInspector:
|
||||
self._cache[key] = _CachedManifest(identity=identity, manifest=manifest)
|
||||
return manifest
|
||||
|
||||
def restore_prepared(
|
||||
self,
|
||||
artifact: RecordedMediaArtifact,
|
||||
replay: ReplayCommand,
|
||||
) -> RecordedMediaManifest | None:
|
||||
"""Restore one previously prepared manifest without rebuilding it.
|
||||
|
||||
A catalog read or process restart must never turn an old camera archive
|
||||
into fresh preparation work. The durable sidecar is accepted only when
|
||||
its complete source stat identity still matches the sealed archive.
|
||||
Missing or stale sidecars remain cold until the operator explicitly
|
||||
requests that session.
|
||||
"""
|
||||
|
||||
if artifact.session_id != replay.session_id:
|
||||
raise SessionIntegrityError("recorded media does not belong to replay session")
|
||||
epoch_paths = _epoch_paths(artifact.source_path)
|
||||
key = (artifact.session_id, artifact.artifact_id)
|
||||
with self._lock:
|
||||
cached = self._cache.get(key)
|
||||
if cached is not None:
|
||||
identity = _prepared_source_identity(
|
||||
replay,
|
||||
epoch_paths,
|
||||
cached.manifest.epochs,
|
||||
)
|
||||
if cached.identity == identity:
|
||||
return cached.manifest
|
||||
prepared = self._load_prepared_sidecar(artifact, replay, epoch_paths)
|
||||
if prepared is None:
|
||||
return None
|
||||
manifest, identity = prepared
|
||||
with self._lock:
|
||||
self._cache[key] = _CachedManifest(identity=identity, manifest=manifest)
|
||||
return manifest
|
||||
|
||||
def _load_prepared_sidecar(
|
||||
self,
|
||||
artifact: RecordedMediaArtifact,
|
||||
|
||||
Reference in New Issue
Block a user