diff --git a/packages/powersync_core/lib/src/bucket_storage.dart b/packages/powersync_core/lib/src/bucket_storage.dart index 56a7ec91..e77257e7 100644 --- a/packages/powersync_core/lib/src/bucket_storage.dart +++ b/packages/powersync_core/lib/src/bucket_storage.dart @@ -53,12 +53,20 @@ class BucketStorage { var count = 0; await writeTransaction((tx) async { + final descriptions = [ + for (final MapEntry(:key, :value) in batch.descriptions.entries) + { + key: {'priority': value.priority}, + } + ]; + for (var b in batch.buckets) { count += b.data.length; await _updateBucket2( tx, jsonEncode({ - 'buckets': [b] + 'buckets': [b], + 'descriptions': descriptions, })); } // No need to flush - the data is not directly visible to the user either way. @@ -352,8 +360,9 @@ class BucketState { final class SyncDataBatch { final List buckets; + final Map descriptions; - SyncDataBatch(this.buckets); + SyncDataBatch(this.buckets, this.descriptions); } class SyncLocalDatabaseResult { diff --git a/packages/powersync_core/lib/src/streaming_sync.dart b/packages/powersync_core/lib/src/streaming_sync.dart index f6d1338a..a8bdf586 100644 --- a/packages/powersync_core/lib/src/streaming_sync.dart +++ b/packages/powersync_core/lib/src/streaming_sync.dart @@ -433,8 +433,9 @@ class StreamingSyncImplementation implements StreamingSync { await adapter.removeBuckets(diff.removedBuckets); adapter.setTargetCheckpoint(targetCheckpoint); case SyncBucketData(): + // TODO: Merge multiple of these into a single one... _updateStatus(downloading: true); - await adapter.saveSyncData(SyncDataBatch([line])); + await adapter.saveSyncData(SyncDataBatch([line], bucketMap)); case StreamingSyncKeepalive(): if (line.tokenExpiresIn == 0) { // Token expired already - stop the connection immediately