fix(restore): clean up staging + session state on cancel/abandon #287

Merged
jmiller merged 1 commits from fix/restore-cancel-cleanup into dev 2026-07-16 16:47:00 +00:00
Owner

Closes #288. Fixes an orphaned-state leak found by the restore-code audit: the restore Cancel button (added in #285) left the server session, .restore.json, and the extracted staging dir behind. Adds SteppedRestoreEngine::cancel() + ajax.restoreCancel (called from the modal before leaving) and a cleanupOldSessions() backstop that reaps orphaned mokosuitebackup-restore- staging dirs. Audit also confirmed the schema (retired sftp_*, VARCHAR include_mokorestore) and PHP 8.3 changes do NOT affect the restore path.

https://claude.ai/code/session_01WbGBN9VyRK61zczYWcCQ2i

Closes #288. Fixes an orphaned-state leak found by the restore-code audit: the restore Cancel button (added in #285) left the server session, *.restore.json, and the extracted staging dir behind. Adds SteppedRestoreEngine::cancel() + ajax.restoreCancel (called from the modal before leaving) and a cleanupOldSessions() backstop that reaps orphaned mokosuitebackup-restore-* staging dirs. Audit also confirmed the schema (retired sftp_*, VARCHAR include_mokorestore) and PHP 8.3 changes do NOT affect the restore path. https://claude.ai/code/session_01WbGBN9VyRK61zczYWcCQ2i
jmiller added 1 commit 2026-07-16 16:46:57 +00:00
The stepped-restore Cancel button (added with the progress-modal controls)
stopped the client loop and reloaded, but left the server-side restore
session, *.restore.json state, and the extracted staging directory behind
with no reaper — so cancelled/abandoned restores leaked disk indefinitely.

- SteppedRestoreEngine::cancel() mirrors the failure-cleanup path (delete
  staging dir + restore state + session).
- AjaxController::restoreCancel() exposes it (token + restore ACL gated).
- Restore modal Cancel now calls ajax.restoreCancel with the session id
  before leaving (session id tracked in restoreSessionId).
- SteppedSession::cleanupOldSessions() also reaps orphaned
  mokosuitebackup-restore-* staging dirs >24h (backstop for browser-close).

Found by an audit of the restore path against recent changes; the schema
(retired sftp_*/VARCHAR include_mokorestore) and PHP 8.3 changes were
confirmed to NOT affect restore.

Claude-Session: https://claude.ai/code/session_01WbGBN9VyRK61zczYWcCQ2i
jmiller force-pushed fix/restore-cancel-cleanup from 8c39fcf3a1 to ab6bee7b51 2026-07-16 16:46:57 +00:00 Compare
jmiller merged commit b0590bef80 into dev 2026-07-16 16:47:00 +00:00
jmiller deleted branch fix/restore-cancel-cleanup 2026-07-16 16:47:01 +00:00
Sign in to join this conversation.