@@ -20,8 +20,6 @@ typedef LocalOperationCounters = ({int atLast, int sinceLast});
2020class BucketStorage {
2121 final SqliteConnection _internalDb;
2222 bool _hasCompletedSync = false ;
23- bool _pendingBucketDeletes = false ;
24- int _compactCounter = compactOperationInterval;
2523
2624 BucketStorage (SqliteConnection db) : _internalDb = db {
2725 _init ();
@@ -67,11 +65,8 @@ class BucketStorage {
6765 }
6866
6967 Future <void > saveSyncData (SyncDataBatch batch) async {
70- var count = 0 ;
71-
7268 await writeTransaction ((tx) async {
7369 for (var b in batch.buckets) {
74- count += b.data.length;
7570 await _updateBucket2 (
7671 tx,
7772 jsonEncode ({
@@ -82,7 +77,6 @@ class BucketStorage {
8277 // We get major initial sync performance improvements with IndexedDB by
8378 // not flushing here.
8479 }, flush: false );
85- _compactCounter += count;
8680 }
8781
8882 Future <void > _updateBucket2 (SqliteWriteContext tx, String json) async {
@@ -103,8 +97,6 @@ class BucketStorage {
10397 ['delete_bucket' , bucket]);
10498 // No need to flush - not directly visible to the user
10599 }, flush: false );
106-
107- _pendingBucketDeletes = true ;
108100 }
109101
110102 Future <bool > hasCompletedSync () async {
@@ -154,8 +146,6 @@ class BucketStorage {
154146 return SyncLocalDatabaseResult (ready: false );
155147 }
156148
157- await forceCompact ();
158-
159149 return SyncLocalDatabaseResult (ready: true );
160150 }
161151
@@ -226,52 +216,6 @@ UPDATE ps_buckets SET count_since_last = 0, count_at_last = ?1->name
226216 }
227217 }
228218
229- Future <void > forceCompact () async {
230- _compactCounter = compactOperationInterval;
231- _pendingBucketDeletes = true ;
232-
233- await autoCompact ();
234- }
235-
236- Future <void > autoCompact () async {
237- // This is a no-op since powersync-sqlite-core v0.3.0
238-
239- // 1. Delete buckets
240- await _deletePendingBuckets ();
241-
242- // 2. Clear REMOVE operations, only keeping PUT ones
243- await _clearRemoveOps ();
244- }
245-
246- Future <void > _deletePendingBuckets () async {
247- // This is a no-op since powersync-sqlite-core v0.3.0
248- if (_pendingBucketDeletes) {
249- // Executed once after start-up, and again when there are pending deletes.
250- await writeTransaction ((tx) async {
251- await tx.execute (
252- 'INSERT INTO powersync_operations(op, data) VALUES (?, ?)' ,
253- ['delete_pending_buckets' , '' ]);
254- // No need to flush - not directly visible to the user
255- }, flush: false );
256- _pendingBucketDeletes = false ;
257- }
258- }
259-
260- Future <void > _clearRemoveOps () async {
261- if (_compactCounter < compactOperationInterval) {
262- return ;
263- }
264-
265- // This is a no-op since powersync-sqlite-core v0.3.0
266- await writeTransaction ((tx) async {
267- await tx.execute (
268- 'INSERT INTO powersync_operations(op, data) VALUES (?, ?)' ,
269- ['clear_remove_ops' , '' ]);
270- // No need to flush - not directly visible to the user
271- }, flush: false );
272- _compactCounter = 0 ;
273- }
274-
275219 void setTargetCheckpoint (Checkpoint checkpoint) {
276220 // No-op for now
277221 }
0 commit comments