fix(store): drop the replaced archive when the new one cannot be written

This commit is contained in:
bchanot committed 2026-10-14 23:15:54 +02:00
1 parent e5e2211476
commit a37c50b9ee
4 files changed
+23 -5

No files matched your search

+3 -1
View File
@@ -266,7 +266,9 @@ export function createReportStore(
) {
/** The archive mirror is explicit: these actions are the session's edges. */
const withArchive = (patch: Patch, archive: ReportArchiveEnvelope | null) => {
archives.save(archive)
// A refused write must not leave the replaced session's archive beside the new draft:
// the next restore would pair them. That archive belongs to the session being replaced.
if (!archives.save(archive)) archives.save(null)
return { ...patch, archive }
}