Skip to content

Commit 0ecd906

Browse files
committed
Set count_at_last in SDK
1 parent a2322df commit 0ecd906

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

packages/powersync_core/lib/src/sync/bucket_storage.dart

+15
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,21 @@ class BucketStorage {
181181
final rs = await tx.execute('SELECT last_insert_rowid() as result');
182182
final result = rs[0]['result'];
183183
if (result == 1) {
184+
if (forPartialPriority == null) {
185+
// Reset progress counters. We only do this for a complete sync, as we
186+
// want a download progress to always cover a complete checkpoint
187+
// instead of resetting for partial completions.
188+
await tx.execute('''
189+
UPDATE ps_buckets SET count_since_last = 0, count_at_last = ?1->name
190+
WHERE ?1->name IS NOT NULL
191+
''', [
192+
json.encode({
193+
for (final bucket in checkpoint.checksums)
194+
if (bucket.count case final count?) bucket.bucket: count,
195+
}),
196+
]);
197+
}
198+
184199
return true;
185200
} else {
186201
// can_update_local(db) == false

0 commit comments

Comments
 (0)