Skip to content

Commit cfdc111

Browse files
committed
Don't require priority on checksum
1 parent ebc2652 commit cfdc111

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

packages/powersync_core/lib/src/sync_types.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,10 @@ class BucketChecksum {
166166

167167
BucketChecksum.fromJson(Map<String, dynamic> json)
168168
: bucket = json['bucket'] as String,
169-
priority = json['priority'] as int,
169+
// Use the default priority (3) as a fallback if the server doesn't send
170+
// priorities. This value is arbitrary though, it won't get used since
171+
// servers not sending priorities also won't send partial checkpoints.
172+
priority = json['priority'] as int? ?? 3,
170173
checksum = json['checksum'] as int,
171174
count = json['count'] as int?,
172175
lastOpId = json['last_op_id'] as String?;

packages/powersync_core/test/in_memory_sync_test.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,15 @@ void main() {
7575
final status = await waitForConnection();
7676

7777
syncService.addLine({
78-
'checkpoint': Checkpoint(
79-
lastOpId: '0',
80-
writeCheckpoint: null,
81-
checksums: [BucketChecksum(bucket: 'bkt', priority: 1, checksum: 0)],
82-
)
78+
'checkpoint': {
79+
'last_op_id': '0',
80+
'buckets': [
81+
{
82+
'bucket': 'bkt',
83+
'checksum': 0,
84+
}
85+
],
86+
},
8387
});
8488
await expectLater(status, emits(isSyncStatus(downloading: true)));
8589

0 commit comments

Comments
 (0)