Replay pending events idempotently while the service owns the database gate.
(
root: &std::path::Path,
store: &atomic_repository::redb_change_store::RedbChangeStore,
)
| 220 | |
| 221 | /// Replay pending events idempotently while the service owns the database gate. |
| 222 | pub fn flush_pending( |
| 223 | root: &std::path::Path, |
| 224 | store: &atomic_repository::redb_change_store::RedbChangeStore, |
| 225 | ) -> Result<(), String> { |
| 226 | for (path, event) in pending(root)? { |
| 227 | store |
| 228 | .append_session_log(&event) |
| 229 | .map_err(|error| error.to_string())?; |
| 230 | let _ = std::fs::remove_file(path); |
| 231 | } |
| 232 | Ok(()) |
| 233 | } |
| 234 | |
| 235 | #[cfg(test)] |
| 236 | mod tests { |