Skip to main content

replay_real_aof/
replay_real_aof.rs

1//! Reproducer: open a `Store` whose data_dir contains a real prod AOF.
2//!
3//! Usage:
4//!     cargo run --example replay_real_aof --release -- <path-to-aof>
5//!
6//! Stages the AOF into a temp dir under the expected `aof-0.aof` name,
7//! then runs the full `Store::open` path so the panic (if any) fires
8//! at the genuine call site rather than a stubbed mock.
9
10use std::path::PathBuf;
11
12use kevy_embedded::{Config, Store};
13
14fn main() {
15    let path = std::env::args()
16        .nth(1)
17        .expect("usage: replay_real_aof <aof-path>");
18    let src = PathBuf::from(&path);
19    let bytes = std::fs::metadata(&src).map_or(0, |m| m.len());
20    println!("reproducer: staging {} bytes from {}", bytes, src.display());
21
22    let dir = std::env::temp_dir().join(format!(
23        "kevy-aof-reproducer-{}",
24        std::process::id()
25    ));
26    std::fs::create_dir_all(&dir).expect("create temp dir");
27    let staged = dir.join("aof-0.aof");
28    std::fs::copy(&src, &staged).expect("copy AOF into staging dir");
29
30    println!("reproducer: opening Store from {}", dir.display());
31    let store = Store::open(
32        Config::default()
33            .with_persist(&dir)
34            .with_aof_filename("aof-0.aof"),
35    )
36    .expect("Store::open");
37
38    println!("reproducer: opened OK; dbsize = {}", store.dbsize());
39}