JournalStore.h header
#include <ew/app/JournalStore.h>
Namespace ew::app
JournalStore class
class ew::app::JournalStore
Reads and appends a project's operation journal on disk.
JSON LINES, ONE ENTRY PER LINE, APPEND-ONLY. The journal only ever grows, so rewriting it whole on every save would cost time proportional to the project's entire history and would fight FolderProjectStore's rule that a save writes only the files that changed. Appending costs only the new entries. It also merges far better: a line-oriented file conflicts at the lines two people actually added, where one ever-growing JSON array conflicts on the whole array.
The file lives INSIDE the project folder, so the history travels with the project and needs no key to associate the two. Keying a per-machine file by the project's folder name would make two projects that happen to share a name silently share one history – and a project has no id of its own to key on instead.
A missing file is an EMPTY journal, not an error: a project that predates journalling, or one never edited since, simply has no history yet. A file that exists but cannot be read IS an error, because silently reporting "no history" for a history that exists would be a lie.
Members
ew::app::journal::JournalStore::JournalStore(QString projectFolder)
Creates a store for the project rooted at projectFolder.
QString ew::app::journal::JournalStore::filePath() const
The full path of the journal file, whether or not it exists.
ew::core::foundation::Result< void > ew::app::journal::JournalStore::append(const std::vector< ew::core::journal::JournalEntry > &entries) const
Appends entries to the journal, creating it if absent. Appending nothing is a no-op that does not create the file. Retries briefly on a transient lock, as project saves do. Const because appending changes the file, not the store: the store is just the path.
ew::core::foundation::Result< ew::core::journal::OperationJournal > ew::app::journal::JournalStore::load() const
Reads the whole journal. An absent file yields an empty journal; a malformed line is an error naming the line, never a silently skipped entry.