@@ -92,11 +92,11 @@ export class SqliteBucketStorage extends BaseObserver<BucketStorageListener> imp
9292 async saveSyncData ( batch : SyncDataBatch , fixedKeyFormat : boolean = false ) {
9393 await this . writeTransaction ( async ( tx ) => {
9494 for ( const b of batch . buckets ) {
95- const result = await tx . execute ( 'INSERT INTO powersync_operations(op, data) VALUES(?, ?)' , [
95+ await tx . execute ( 'INSERT INTO powersync_operations(op, data) VALUES(?, ?)' , [
9696 'save' ,
9797 JSON . stringify ( { buckets : [ b . toJSON ( fixedKeyFormat ) ] } )
9898 ] ) ;
99- this . logger . debug ( 'saveSyncData' , JSON . stringify ( result ) ) ;
99+ this . logger . debug ( `Saved batch of data for bucket: ${ b . bucket } , operations: ${ b . data . length } ` ) ;
100100 }
101101 } ) ;
102102 }
@@ -115,7 +115,7 @@ export class SqliteBucketStorage extends BaseObserver<BucketStorageListener> imp
115115 await tx . execute ( 'INSERT INTO powersync_operations(op, data) VALUES(?, ?)' , [ 'delete_bucket' , bucket ] ) ;
116116 } ) ;
117117
118- this . logger . debug ( 'done deleting bucket' ) ;
118+ this . logger . debug ( `Done deleting bucket ${ bucket } ` ) ;
119119 }
120120
121121 async hasCompletedSync ( ) {
@@ -139,6 +139,11 @@ export class SqliteBucketStorage extends BaseObserver<BucketStorageListener> imp
139139 }
140140 return { ready : false , checkpointValid : false , checkpointFailures : r . checkpointFailures } ;
141141 }
142+ if ( priority == null ) {
143+ this . logger . debug ( `Validated checksums checkpoint ${ checkpoint . last_op_id } ` ) ;
144+ } else {
145+ this . logger . debug ( `Validated checksums for partial checkpoint ${ checkpoint . last_op_id } , priority ${ priority } ` ) ;
146+ }
142147
143148 let buckets = checkpoint . buckets ;
144149 if ( priority !== undefined ) {
@@ -158,7 +163,6 @@ export class SqliteBucketStorage extends BaseObserver<BucketStorageListener> imp
158163
159164 const valid = await this . updateObjectsFromBuckets ( checkpoint , priority ) ;
160165 if ( ! valid ) {
161- this . logger . debug ( 'Not at a consistent checkpoint - cannot update local db' ) ;
162166 return { ready : false , checkpointValid : true } ;
163167 }
164168
@@ -221,7 +225,6 @@ export class SqliteBucketStorage extends BaseObserver<BucketStorageListener> imp
221225 ] ) ;
222226
223227 const resultItem = rs . rows ?. item ( 0 ) ;
224- this . logger . debug ( 'validateChecksums priority, checkpoint, result item' , priority , checkpoint , resultItem ) ;
225228 if ( ! resultItem ) {
226229 return {
227230 checkpointValid : false ,
@@ -262,34 +265,32 @@ export class SqliteBucketStorage extends BaseObserver<BucketStorageListener> imp
262265
263266 const opId = await cb ( ) ;
264267
265- this . logger . debug ( `[updateLocalTarget] Updating target to checkpoint ${ opId } ` ) ;
266-
267268 return this . writeTransaction ( async ( tx ) => {
268269 const anyData = await tx . execute ( 'SELECT 1 FROM ps_crud LIMIT 1' ) ;
269270 if ( anyData . rows ?. length ) {
270271 // if isNotEmpty
271- this . logger . debug ( 'updateLocalTarget' , 'ps crud is not empty' ) ;
272+ this . logger . debug ( `New data uploaded since write checkpoint ${ opId } - need new write checkpoint` ) ;
272273 return false ;
273274 }
274275
275276 const rs = await tx . execute ( "SELECT seq FROM sqlite_sequence WHERE name = 'ps_crud'" ) ;
276277 if ( ! rs . rows ?. length ) {
277278 // assert isNotEmpty
278- throw new Error ( 'SQlite Sequence should not be empty' ) ;
279+ throw new Error ( 'SQLite Sequence should not be empty' ) ;
279280 }
280281
281282 const seqAfter : number = rs . rows ?. item ( 0 ) [ 'seq' ] ;
282- this . logger . debug ( 'seqAfter' , JSON . stringify ( rs . rows ?. item ( 0 ) ) ) ;
283283 if ( seqAfter != seqBefore ) {
284- this . logger . debug ( 'seqAfter != seqBefore' , seqAfter , seqBefore ) ;
284+ this . logger . debug (
285+ `New data uploaded since write checpoint ${ opId } - need new write checkpoint (sequence updated)`
286+ ) ;
287+
285288 // New crud data may have been uploaded since we got the checkpoint. Abort.
286289 return false ;
287290 }
288291
289- const response = await tx . execute ( "UPDATE ps_buckets SET target_op = CAST(? as INTEGER) WHERE name='$local'" , [
290- opId
291- ] ) ;
292- this . logger . debug ( [ '[updateLocalTarget] Response from updating target_op ' , JSON . stringify ( response ) ] ) ;
292+ this . logger . debug ( `Updating target write checkpoint to ${ opId } ` ) ;
293+ await tx . execute ( "UPDATE ps_buckets SET target_op = CAST(? as INTEGER) WHERE name='$local'" , [ opId ] ) ;
293294 return true ;
294295 } ) ;
295296 }
0 commit comments