@@ -14,7 +14,12 @@ use alloc::{
1414} ;
1515use futures_lite:: FutureExt ;
1616
17- use crate :: { bson, error:: SQLiteError , kv:: client_id, sync:: checkpoint:: OwnedBucketChecksum } ;
17+ use crate :: {
18+ bson,
19+ error:: SQLiteError ,
20+ kv:: client_id,
21+ sync:: { checkpoint:: OwnedBucketChecksum , interface:: StartSyncStream } ,
22+ } ;
1823use sqlite_nostd:: { self as sqlite, ResultCode } ;
1924
2025use super :: {
@@ -52,7 +57,7 @@ impl SyncClient {
5257 SyncControlRequest :: StartSyncStream ( options) => {
5358 self . state . tear_down ( ) ?;
5459
55- let mut handle = SyncIterationHandle :: new ( self . db , options. parameters ) ?;
60+ let mut handle = SyncIterationHandle :: new ( self . db , options) ?;
5661 let instructions = handle. initialize ( ) ?;
5762 self . state = ClientState :: IterationActive ( handle) ;
5863
@@ -120,13 +125,10 @@ struct SyncIterationHandle {
120125impl SyncIterationHandle {
121126 /// Creates a new sync iteration in a pending state by preparing statements for
122127 /// [StorageAdapter] and setting up the initial downloading state for [StorageAdapter] .
123- fn new (
124- db : * mut sqlite:: sqlite3 ,
125- parameters : Option < serde_json:: Map < String , serde_json:: Value > > ,
126- ) -> Result < Self , ResultCode > {
128+ fn new ( db : * mut sqlite:: sqlite3 , options : StartSyncStream ) -> Result < Self , ResultCode > {
127129 let runner = StreamingSyncIteration {
128130 db,
129- parameters ,
131+ options ,
130132 adapter : StorageAdapter :: new ( db) ?,
131133 status : SyncStatusContainer :: new ( ) ,
132134 } ;
@@ -191,7 +193,7 @@ impl<'a> ActiveEvent<'a> {
191193struct StreamingSyncIteration {
192194 db : * mut sqlite:: sqlite3 ,
193195 adapter : StorageAdapter ,
194- parameters : Option < serde_json :: Map < String , serde_json :: Value > > ,
196+ options : StartSyncStream ,
195197 status : SyncStatusContainer ,
196198}
197199
@@ -244,7 +246,9 @@ impl StreamingSyncIteration {
244246 SyncEvent :: BinaryLine { data } => bson:: from_bytes ( data) ?,
245247 SyncEvent :: UploadFinished => {
246248 if let Some ( checkpoint) = validated_but_not_applied. take ( ) {
247- let result = self . adapter . sync_local ( & checkpoint, None ) ?;
249+ let result =
250+ self . adapter
251+ . sync_local ( & checkpoint, None , & self . options . schema ) ?;
248252
249253 match result {
250254 SyncLocalResult :: ChangesApplied => {
@@ -320,7 +324,9 @@ impl StreamingSyncIteration {
320324 ) ,
321325 ) ) ;
322326 } ;
323- let result = self . adapter . sync_local ( target, None ) ?;
327+ let result = self
328+ . adapter
329+ . sync_local ( target, None , & self . options . schema ) ?;
324330
325331 match result {
326332 SyncLocalResult :: ChecksumFailure ( checkpoint_result) => {
@@ -363,7 +369,9 @@ impl StreamingSyncIteration {
363369 ) ,
364370 ) ) ;
365371 } ;
366- let result = self . adapter . sync_local ( target, Some ( priority) ) ?;
372+ let result =
373+ self . adapter
374+ . sync_local ( target, Some ( priority) , & self . options . schema ) ?;
367375
368376 match result {
369377 SyncLocalResult :: ChecksumFailure ( checkpoint_result) => {
@@ -459,7 +467,7 @@ impl StreamingSyncIteration {
459467 raw_data : true ,
460468 binary_data : true ,
461469 client_id : client_id ( self . db ) ?,
462- parameters : self . parameters . take ( ) ,
470+ parameters : self . options . parameters . take ( ) ,
463471 } ;
464472
465473 event
0 commit comments