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 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HS8WZziDnyxunC23MUxrLp
This commit is contained in:
1 parent
c1bd890784
commit
1cc8d96740
1 file changed
+16
-1
@@ -125,13 +125,28 @@ fn line_types(dir: &Path) -> Vec<String> {
|
||||
.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<PathBuf, Vec<u8>> {
|
||||
fn walk(root: &Path, d: &Path, out: &mut BTreeMap<PathBuf, Vec<u8>>) {
|
||||
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(),
|
||||
|
||||
Reference in new issue
Block a user