Skip to content

Commit ae16b5b

Browse files
committed
fix arguments for libsql_wal_insert_frame FFI call
- someone was drunk when these methods was added 🍻
1 parent 8c2536c commit ae16b5b

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

libsql/src/local/connection.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -584,14 +584,14 @@ impl Connection {
584584
Ok(())
585585
}
586586

587-
fn wal_insert_frame(&self, frame: &[u8]) -> Result<()> {
587+
fn wal_insert_frame(&self, frame_no: u32, frame: &[u8]) -> Result<()> {
588588
let mut conflict = 0i32;
589589
let rc = unsafe {
590590
libsql_sys::ffi::libsql_wal_insert_frame(
591591
self.handle(),
592-
frame.len() as u32,
592+
frame_no,
593593
frame.as_ptr() as *mut std::ffi::c_void,
594-
0,
594+
frame.len() as u32,
595595
&mut conflict,
596596
)
597597
};
@@ -666,13 +666,13 @@ unsafe extern "C" fn authorizer_callback(
666666

667667
pub(crate) struct WalInsertHandle<'a> {
668668
conn: &'a Connection,
669-
in_session: RefCell<bool>
669+
in_session: RefCell<bool>,
670670
}
671671

672672
impl WalInsertHandle<'_> {
673-
pub fn insert(&self, frame: &[u8]) -> Result<()> {
673+
pub fn insert_at(&self, frame_no: u32, frame: &[u8]) -> Result<()> {
674674
assert!(*self.in_session.borrow());
675-
self.conn.wal_insert_frame(frame)
675+
self.conn.wal_insert_frame(frame_no, frame)
676676
}
677677

678678
pub fn begin(&self) -> Result<()> {

libsql/src/sync.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -974,8 +974,8 @@ pub async fn try_pull(
974974
);
975975
return Err(SyncError::InvalidPullFrameBytes(frames.len()).into());
976976
}
977-
for chunk in frames.chunks(FRAME_SIZE) {
978-
let r = insert_handle.insert(&chunk);
977+
for (i, chunk) in frames.chunks(FRAME_SIZE).enumerate() {
978+
let r = insert_handle.insert_at(frame_no + i as u32, &chunk);
979979
if let Err(e) = r {
980980
tracing::error!(
981981
"insert error (frame= {}) : {:?}",

0 commit comments

Comments
 (0)