Read a batch file written by zot
zotReadBatch.RdReads a plan, preview, approval or ledger file and rebuilds the
corresponding object. A preview is rebuilt through zotPreview(), so its
digest is recalculated from the rows on disk and compared with the stored
one: a file edited after it was written is refused.
Arguments
- path
A file written by
zotWriteBatch()orzotExecute().- digest
Optional expected SHA-256 digest; a mismatch is refused.
Details
A ledger has no kind; it is recognized by its digest and items and
returned as the zotLedger list that zotExecute() produces. A plan has no
stored digest; when digest is supplied for a plan it is compared with the
digest the plan would have under zotPreview().
Examples
Plan <- data.table::data.table(
action = "patch", library = "user", itemKey = "ABCD1234",
payload = list(list(title = "A reviewed title"))
)
Preview <- zotPreview(Plan, describe = "Correct one title")
Path <- tempfile(fileext = ".json")
zotWriteBatch(Preview, Path)
identical(zotReadBatch(Path)$digest, Preview$digest)
#> [1] TRUE
unlink(Path)