mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-06 17:54:20 +01:00
mvcc: add truncate method to logical log
This commit is contained in:
@@ -184,4 +184,15 @@ impl LogicalLog {
|
||||
let c = self.file.sync(completion)?;
|
||||
Ok(IOResult::IO(IOCompletions::Single(c)))
|
||||
}
|
||||
|
||||
pub fn truncate(&mut self) -> Result<IOResult<()>> {
|
||||
let completion = Completion::new_trunc(move |result| {
|
||||
if let Err(err) = result {
|
||||
tracing::error!("logical_log_truncate failed: {}", err);
|
||||
}
|
||||
});
|
||||
let c = self.file.truncate(0, completion)?;
|
||||
self.offset = 0;
|
||||
Ok(IOResult::IO(IOCompletions::Single(c)))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,6 +31,10 @@ impl Storage {
|
||||
pub fn sync(&self) -> Result<IOResult<()>> {
|
||||
self.logical_log.write().unwrap().sync()
|
||||
}
|
||||
|
||||
pub fn truncate(&self) -> Result<IOResult<()>> {
|
||||
self.logical_log.write().unwrap().truncate()
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for Storage {
|
||||
|
||||
Reference in New Issue
Block a user