Running documents

Storage and saving

The working copy, durability states, transactions, saving and conflicts.

The working copy

When a document opens, the reader copies storage/** into a working copy (an overlay). read and list see the working copy; write and delete change only the working copy. The file on disk is not modified until the user saves. There is no autosave into the package.

Paths are relative to storage/ and follow the package path rules. A path that escapes storage/ is refused (IDOP-PATH-020).

Storage holds UTF-8 text. Store structured data as JSON.

Durability

Readers show which of three states a document is in:

State Meaning
memory the document changed its own model but has not written to storage
session the working copy changed; the file has not
file the latest working copy is saved in the file

Write to storage as soon as the user changes something meaningful, so the reader can show session and offer to save.

Transactions

idop.storage.transaction applies several writes and deletes atomically:

await idop.storage.transaction([
  { op: 'write', path: 'cards.json', data: JSON.stringify(cards) },
  { op: 'delete', path: 'draft.json' },
]);

Saving

idop.ui.requestSave() asks the reader to show its own Save control; the decision stays with the user. On save, the reader builds a new package that differs only in storage/ and the revision fields of idop.json, validates it completely, and replaces the old file.

If the file changed on disk since it was opened, the reader does not overwrite it (IDOP-SAVE-CONFLICT) and offers Save as instead.

Quota

Readers limit the size of storage. A write over the limit fails with IDOP-STORAGE-QUOTA.