@@ -94,11 +94,11 @@ export class SqliteBucketStorage extends BaseObserver<BucketStorageListener> imp
9494 async saveSyncData ( batch : SyncDataBatch , fixedKeyFormat : boolean = false ) {
9595 await this . writeTransaction ( async ( tx ) => {
9696 for ( const b of batch . buckets ) {
97- const result = await tx . execute ( 'INSERT INTO powersync_operations(op, data) VALUES(?, ?)' , [
97+ await tx . execute ( 'INSERT INTO powersync_operations(op, data) VALUES(?, ?)' , [
9898 'save' ,
9999 JSON . stringify ( { buckets : [ b . toJSON ( fixedKeyFormat ) ] } )
100100 ] ) ;
101- this . logger . debug ( 'saveSyncData' , JSON . stringify ( result ) ) ;
101+ this . logger . debug ( `Saved batch of data for bucket: ${ b . bucket } , operations: ${ b . data . length } ` ) ;
102102 }
103103 } ) ;
104104 }
@@ -117,7 +117,7 @@ export class SqliteBucketStorage extends BaseObserver<BucketStorageListener> imp
117117 await tx . execute ( 'INSERT INTO powersync_operations(op, data) VALUES(?, ?)' , [ 'delete_bucket' , bucket ] ) ;
118118 } ) ;
119119
120- this . logger . debug ( 'done deleting bucket' ) ;
120+ this . logger . debug ( `Done deleting bucket ${ bucket } ` ) ;
121121 }
122122
123123 async hasCompletedSync ( ) {
@@ -141,6 +141,11 @@ export class SqliteBucketStorage extends BaseObserver<BucketStorageListener> imp
141141 }
142142 return { ready : false , checkpointValid : false , checkpointFailures : r . checkpointFailures } ;
143143 }
144+ if ( priority == null ) {
145+ this . logger . debug ( `Validated checksums checkpoint ${ checkpoint . last_op_id } ` ) ;
146+ } else {
147+ this . logger . debug ( `Validated checksums for partial checkpoint ${ checkpoint . last_op_id } , priority ${ priority } ` ) ;
148+ }
144149
145150 let buckets = checkpoint . buckets ;
146151 if ( priority !== undefined ) {
@@ -160,7 +165,6 @@ export class SqliteBucketStorage extends BaseObserver<BucketStorageListener> imp
160165
161166 const valid = await this . updateObjectsFromBuckets ( checkpoint , priority ) ;
162167 if ( ! valid ) {
163- this . logger . debug ( 'Not at a consistent checkpoint - cannot update local db' ) ;
164168 return { ready : false , checkpointValid : true } ;
165169 }
166170
@@ -223,7 +227,6 @@ export class SqliteBucketStorage extends BaseObserver<BucketStorageListener> imp
223227 ] ) ;
224228
225229 const resultItem = rs . rows ?. item ( 0 ) ;
226- this . logger . debug ( 'validateChecksums priority, checkpoint, result item' , priority , checkpoint , resultItem ) ;
227230 if ( ! resultItem ) {
228231 return {
229232 checkpointValid : false ,
@@ -264,34 +267,32 @@ export class SqliteBucketStorage extends BaseObserver<BucketStorageListener> imp
264267
265268 const opId = await cb ( ) ;
266269
267- this . logger . debug ( `[updateLocalTarget] Updating target to checkpoint ${ opId } ` ) ;
268-
269270 return this . writeTransaction ( async ( tx ) => {
270271 const anyData = await tx . execute ( 'SELECT 1 FROM ps_crud LIMIT 1' ) ;
271272 if ( anyData . rows ?. length ) {
272273 // if isNotEmpty
273- this . logger . debug ( 'updateLocalTarget' , 'ps crud is not empty' ) ;
274+ this . logger . debug ( `New data uploaded since write checkpoint ${ opId } - need new write checkpoint` ) ;
274275 return false ;
275276 }
276277
277278 const rs = await tx . execute ( "SELECT seq FROM sqlite_sequence WHERE name = 'ps_crud'" ) ;
278279 if ( ! rs . rows ?. length ) {
279280 // assert isNotEmpty
280- throw new Error ( 'SQlite Sequence should not be empty' ) ;
281+ throw new Error ( 'SQLite Sequence should not be empty' ) ;
281282 }
282283
283284 const seqAfter : number = rs . rows ?. item ( 0 ) [ 'seq' ] ;
284- this . logger . debug ( 'seqAfter' , JSON . stringify ( rs . rows ?. item ( 0 ) ) ) ;
285285 if ( seqAfter != seqBefore ) {
286- this . logger . debug ( 'seqAfter != seqBefore' , seqAfter , seqBefore ) ;
286+ this . logger . debug (
287+ `New data uploaded since write checpoint ${ opId } - need new write checkpoint (sequence updated)`
288+ ) ;
289+
287290 // New crud data may have been uploaded since we got the checkpoint. Abort.
288291 return false ;
289292 }
290293
291- const response = await tx . execute ( "UPDATE ps_buckets SET target_op = CAST(? as INTEGER) WHERE name='$local'" , [
292- opId
293- ] ) ;
294- this . logger . debug ( [ '[updateLocalTarget] Response from updating target_op ' , JSON . stringify ( response ) ] ) ;
294+ this . logger . debug ( `Updating target write checkpoint to ${ opId } ` ) ;
295+ await tx . execute ( "UPDATE ps_buckets SET target_op = CAST(? as INTEGER) WHERE name='$local'" , [ opId ] ) ;
295296 return true ;
296297 } ) ;
297298 }
0 commit comments