mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-02 16:04:20 +01:00
impl remove_file for MemoryIO + skip completion if finished
This commit is contained in:
@@ -53,6 +53,16 @@ impl OperationType {
|
||||
| OperationType::Truncate { fd, .. } => fd,
|
||||
}
|
||||
}
|
||||
|
||||
fn get_completion(&self) -> &Completion {
|
||||
match self {
|
||||
OperationType::Read { completion, .. }
|
||||
| OperationType::Write { completion, .. }
|
||||
| OperationType::WriteV { completion, .. }
|
||||
| OperationType::Sync { completion, .. }
|
||||
| OperationType::Truncate { completion, .. } => completion,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Operation {
|
||||
@@ -262,6 +272,10 @@ impl IO for MemorySimIO {
|
||||
callbacks.append(&mut timeouts);
|
||||
|
||||
while let Some(callback) = callbacks.pop() {
|
||||
let completion = callback.op.get_completion();
|
||||
if completion.finished() {
|
||||
continue;
|
||||
}
|
||||
if callback.time.is_none() || callback.time.is_some_and(|time| time < now) {
|
||||
// TODO: check if we should inject fault in operation here
|
||||
callback.do_operation(&files);
|
||||
@@ -275,4 +289,9 @@ impl IO for MemorySimIO {
|
||||
fn generate_random_number(&self) -> i64 {
|
||||
self.rng.borrow_mut().next_u64() as i64
|
||||
}
|
||||
|
||||
fn remove_file(&self, path: &str) -> Result<()> {
|
||||
self.files.borrow_mut().shift_remove(path);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user