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)
20        .map(|m| m.len())
21        .unwrap_or(0);
22    println!("reproducer: staging {} bytes from {}", bytes, src.display());
23
24    let dir = std::env::temp_dir().join(format!(
25        "kevy-aof-reproducer-{}",
26        std::process::id()
27    ));
28    std::fs::create_dir_all(&dir).expect("create temp dir");
29    let staged = dir.join("aof-0.aof");
30    std::fs::copy(&src, &staged).expect("copy AOF into staging dir");
31
32    println!("reproducer: opening Store from {}", dir.display());
33    let store = Store::open(
34        Config::default()
35            .with_persist(&dir)
36            .with_aof_filename("aof-0.aof"),
37    )
38    .expect("Store::open");
39
40    println!("reproducer: opened OK; dbsize = {}", store.dbsize());
41}