def swap

bend-kit-runner@0.13.0.1 · runner.bend:1486

import bend-kit-runner@0.13.0.1/runner.bend as Runner
import Base
import bend-kit-bytes@0.3.3.0/bytes.bend as Bytes
import bend-kit-journal@0.3.0.1/journal.bend as J
import bend-kit-files@0.3.0.0/files.bend as Files

1486# Writes snap as the only record of path.compact, fsyncs it, and renames it over path.
1487def swap(+path: String, +limit: U32, snap: Bytes.Bytes) -> IO(Swap):
1488  +tmp = path ++ ".compact"
1489  do IO<Swap>:
1490    gone : Out(Unit) <- Files.remove(tmp)
1491    x : Out(J.Journal & Unit) <- J.open(~Unit, ~(a => b => a), tmp, limit, limit, Unit{})
1492    swap.opened(path, tmp, limit, x, snap)

Uses (14)

Used by (1)