test(sessiond): harden archive migration safety

This commit is contained in:
Federico Jaramillo Martinez
2026-07-13 14:45:14 +02:00
parent 31c98454ec
commit 050b053d23
3 changed files with 153 additions and 8 deletions
+2 -2
View File
@@ -2,6 +2,6 @@
"@jmfederico/pi-web": patch
---
Store session archive metadata and archived session files under `PI_WEB_DATA_DIR` when configured.
Store session archive metadata and archived session files under `PI_WEB_DATA_DIR` when configured, and automatically migrate a legacy archive on the first eligible session-daemon startup after upgrading.
Previously, session archives always used `~/.pi-web`, even when `PI_WEB_DATA_DIR` selected another managed-state root. Existing archives created with a custom `PI_WEB_DATA_DIR` remain in `~/.pi-web` and are not migrated automatically. Before upgrading, stop the session daemon and back up both locations before reconciling them manually. Because the archive index stores absolute `archivePath` values, update those values when moving archived files.
Migration runs only when `PI_WEB_DATA_DIR` explicitly selects a different root, the legacy index and every referenced file form a complete valid archive, and the destination archive is pristine. PI WEB copies and verifies files across filesystem boundaries, rewrites their `archivePath` values, atomically commits the destination index, and only then removes legacy archive state. Ambiguous, invalid, partial, or coexisting layouts are left untouched instead of being merged or overwritten; active Pi session files are never moved.