From 1cc8d967407749fce7f61b828ae348660a396075 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Fri, 30 Oct 2026 12:00:55 -0600 Subject: [PATCH] test(store): the tree helper skips the live SQLite files (P11c) spec_store's tree() read every file under the root while a Store was open; on Windows SQLite holds byte-range locks on its database, so the read failed (os error 33) in two tests. The lock seam locks only wanderbooks.lock, never data, so it is not the cause. tree() now leaves out the live database and its -wal/-shm/-journal; the tests compare the journal, blobs and kept-aside files. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_01HS8WZziDnyxunC23MUxrLp --- crates/ledger-store/tests/spec_store.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/crates/ledger-store/tests/spec_store.rs b/crates/ledger-store/tests/spec_store.rs index 447724b..5f13dca 100644 --- a/crates/ledger-store/tests/spec_store.rs +++ b/crates/ledger-store/tests/spec_store.rs @@ -125,13 +125,28 @@ fn line_types(dir: &Path) -> Vec { .collect() } -/// Every file under `dir` (relative path → bytes). +/// Whether `p` is the live SQLite database or one of its companions. +fn is_live_database(p: &Path) -> bool { + let name = p.file_name().unwrap().to_string_lossy().into_owned(); + let db = db_file(); + name == db + || ["-wal", "-shm", "-journal"] + .iter() + .any(|x| name == format!("{db}{x}")) +} + +/// Every file under `dir` (relative path → bytes), the live database and +/// its companions left out. fn tree(dir: &Path) -> BTreeMap> { fn walk(root: &Path, d: &Path, out: &mut BTreeMap>) { for e in std::fs::read_dir(d).unwrap() { let p = e.unwrap().path(); if p.is_dir() { walk(root, &p, out); + } else if p.parent() == Some(root) && is_live_database(&p) { + // An open SQLite connection holds byte-range locks on its + // database file on Windows: a plain read is refused. The + // tests compare the journal, blobs and kept-aside files. } else { out.insert( p.strip_prefix(root).unwrap().to_path_buf(),