mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-03 17:48:17 +00:00
core: fix completion generic io
This commit is contained in:
parent
2b221d2b3c
commit
82ee0e4a00
1 changed files with 9 additions and 5 deletions
|
@ -1,4 +1,4 @@
|
|||
use crate::{Completion, File, Result, WriteCompletion, IO};
|
||||
use crate::{Completion, File, Result, IO};
|
||||
use log::trace;
|
||||
use std::cell::RefCell;
|
||||
use std::io::{Read, Seek, Write};
|
||||
|
@ -45,11 +45,15 @@ impl File for GenericFile {
|
|||
let mut file = self.file.borrow_mut();
|
||||
file.seek(std::io::SeekFrom::Start(pos as u64))?;
|
||||
{
|
||||
let mut buf = c.buf_mut();
|
||||
let r = match &(*c) {
|
||||
Completion::Read(r) => r,
|
||||
Completion::Write(_) => unreachable!(),
|
||||
};
|
||||
let mut buf = r.buf_mut();
|
||||
let buf = buf.as_mut_slice();
|
||||
file.read_exact(buf)?;
|
||||
}
|
||||
c.complete();
|
||||
c.complete(0);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -57,7 +61,7 @@ impl File for GenericFile {
|
|||
&self,
|
||||
pos: usize,
|
||||
buffer: Rc<RefCell<crate::Buffer>>,
|
||||
c: Rc<WriteCompletion>,
|
||||
c: Rc<Completion>,
|
||||
) -> Result<()> {
|
||||
let mut file = self.file.borrow_mut();
|
||||
file.seek(std::io::SeekFrom::Start(pos as u64))?;
|
||||
|
@ -72,4 +76,4 @@ impl Drop for GenericFile {
|
|||
fn drop(&mut self) {
|
||||
self.unlock_file().expect("Failed to unlock file");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue