# `PhoenixReplay.Storage.File`
[🔗](https://github.com/elixir-vibe/phoenix_replay/blob/v0.6.2/lib/phoenix_replay/storage/file.ex#L1)

Stores each recording as two files in a directory.

`<id>.recording` holds the full recording and `<id>.summary` holds its
`PhoenixReplay.Recording.Summary`, so listing never decodes recordings.
The summary is written last and deleted first: a summary file always points
at a complete recording. Both are written to a temporary file, synced and
renamed into place, so a crash never leaves half a recording.

While a session runs, its chunks are appended to `<id>.<node>-<pid>.part`
as frames (see `PhoenixReplay.Storage.Codec.frame/1`), and saving the
finished recording deletes the part file. Part files carry a tag of the
node and host that wrote them, and the OS process id of the VM, so
instances sharing a directory, in a cluster or not, only recover their
own, and only once the VM that wrote them is gone: an `iex -S mix` or
`mix phoenix_replay.export` started next to a running server leaves its
sessions alone. Parts left by an instance that never starts again under
the same node and host name are not recovered.

Summaries are kept in an ETS index once read, so listing reads only the
summary files it has not seen. The directory's file names stay the
source of truth: files another node wrote or deleted are picked up on
the next list.

## Options

  * `:path` — directory for recording files (default: `"priv/replay_recordings"`).
    A relative path is resolved against the working directory when
    PhoenixReplay started, not when a file is written: the working
    directory belongs to the whole VM, and tools such as Phoenix's code
    reloader change it while they compile a path dependency.
  * `:sync` — whether to sync each appended chunk to disk. A plain write
    survives a crash of the node; syncing also survives losing power or
    the operating system, at a cost per chunk. Defaults to `false`.
    Finished recordings are always synced.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
