diff options
| author | tv <tv@krebsco.de> | 2026-11-30 18:21:16 +0000 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-11-30 19:51:09 +0000 |
| commit | b74359e97643be0f43034c3aeab533a2389a939f (patch) | |
| tree | 4f13dc922acb8f7bef53ca3e787d0a296692bb52 /src/plan.rs | |
| parent | 62f857e35f94e98b3205502e410f0d727fa5ecc5 (diff) | |
enstate: submissions waiting for the next switch
--migrate first takes the submissions in STATE/incoming, in the order of
their names: planned against the schema, stored if accepted (their views
follow with the rest), removed, and moved to STATE/refused if refused,
which refuses the migration. A dry run (the check before a switch) does
so on a copy of the snapshots, changing nothing. --stage leaves a
marker, STATE/migrate-due, for the next switch to migrate even if the
schema doesn't change; --migrate removes it. Scratch directories are
cleaned up without following the symbolic links in them.
Diffstat (limited to 'src/plan.rs')
| -rw-r--r-- | src/plan.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/plan.rs b/src/plan.rs index 9a56505..b37510d 100644 --- a/src/plan.rs +++ b/src/plan.rs @@ -514,8 +514,22 @@ impl Planned { /// in place and no reactions run: those of the running generation stay as they /// are, and the switch (`--migrate`) brings the new generation's. The running /// generation sees the snapshot as any accepted under another schema: what it has - /// no slot for is kept. + /// no slot for is kept. A staged snapshot leaves a marker, so that the next switch + /// serves the views anew, even if the schema doesn't change. pub fn stage(self, store: &Store, schema_bytes: &[u8], lock: Lock) -> Result<Plan> { + let plan = self.store(store, schema_bytes)?; + if plan.snapshot.is_some() { + std::fs::write(store.migrate_due(), b"") + .with_context(|| format!("writing {}", store.migrate_due().display()))?; + } + drop(lock); + Ok(plan) + } + + /// Stores the new snapshot, if the plan was accepted, and nothing else: no views, + /// no reactions. For staging, and for submissions taken from the incoming + /// directory, whose views `--migrate` puts in place after. + pub fn store(self, store: &Store, schema_bytes: &[u8]) -> Result<Plan> { let mut plan = self.plan; plan.staged = true; if plan.accepted && self.content_changes { @@ -527,7 +541,6 @@ impl Planned { schema_bytes, )?); } - drop(lock); Ok(plan) } } |
