mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-03 08:24:19 +01:00
persist files in sim memory io for integrity check
This commit is contained in:
@@ -79,6 +79,11 @@ impl SimIO for SimulatorIO {
|
||||
fn close_files(&self) {
|
||||
self.files.borrow_mut().clear()
|
||||
}
|
||||
|
||||
fn persist_files(&self) -> anyhow::Result<()> {
|
||||
// Files are persisted automatically
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Clock for SimulatorIO {
|
||||
|
||||
@@ -190,6 +190,17 @@ impl SimIO for MemorySimIO {
|
||||
file.closed.set(true);
|
||||
}
|
||||
}
|
||||
|
||||
fn persist_files(&self) -> anyhow::Result<()> {
|
||||
let files = self.files.borrow();
|
||||
for (file_path, file) in files.iter() {
|
||||
if file_path.ends_with(".db") || file_path.ends_with("wal") || file_path.ends_with("lg")
|
||||
{
|
||||
std::fs::write(file_path, &*file.buffer.borrow())?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Clock for MemorySimIO {
|
||||
|
||||
@@ -20,4 +20,6 @@ pub trait SimIO: turso_core::IO {
|
||||
fn syncing(&self) -> bool;
|
||||
|
||||
fn close_files(&self);
|
||||
|
||||
fn persist_files(&self) -> anyhow::Result<()>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user