Scans the swap directory for orphaned swap files and determines which ones are recoverable.
A swap file is recoverable when:
- It parses correctly (valid MINGA_SWAP_V1 header)
- The OS PID that wrote it is no longer alive (
kill -0check) - The original file still exists on disk
Swap files written by a still-running Minga instance are left alone. Corrupt swap files are cleaned up automatically.
Summary
Functions
Deletes a swap file (user declined recovery).
Recovers content from a swap file.
Scans the swap directory and returns a list of recoverable entries.
Types
Functions
@spec discard(String.t()) :: :ok
Deletes a swap file (user declined recovery).
Recovers content from a swap file.
Returns {:ok, file_path, content} where content is the unsaved
buffer text. The caller is responsible for opening a buffer with
this content and marking it as dirty. The swap file is deleted
after successful recovery.
Scans the swap directory and returns a list of recoverable entries.
Each entry contains the original file path, the swap file path, and the swap file's mtime. The caller decides what to do with them (show a recovery prompt, auto-recover, etc.).
Options
:swap_dir- override the default swap directory (for testing):pid_alive?- override the PID liveness check (for testing)