Skip to main content

commit_plan

Function commit_plan 

Source
pub fn commit_plan(
    plan: &Path,
    expected: Option<&str>,
    json: &str,
) -> Result<Vec<String>, Error>
Expand description

Replace PLAN.json with json only when its bytes are still expected. None means the plan was absent when it was read. A mismatch leaves the file untouched and returns an error whose message says the plan changed.

Callers of this function take one writer lock on a sibling of the plan, so two of them cannot overwrite each other. A writer that does not call it is not blocked. A change that lands before the locked re-read is refused rather than overwritten.

§Errors

std::io::ErrorKind::AlreadyExists when expected is not the plan’s current bytes. The same I/O errors as write_plan when the publish fails. WASM has no filesystem publication.