@@ -20,8 +20,6 @@ typedef LocalOperationCounters = ({int atLast, int sinceLast});
20
20
class BucketStorage {
21
21
final SqliteConnection _internalDb;
22
22
bool _hasCompletedSync = false ;
23
- bool _pendingBucketDeletes = false ;
24
- int _compactCounter = compactOperationInterval;
25
23
26
24
BucketStorage (SqliteConnection db) : _internalDb = db {
27
25
_init ();
@@ -67,11 +65,8 @@ class BucketStorage {
67
65
}
68
66
69
67
Future <void > saveSyncData (SyncDataBatch batch) async {
70
- var count = 0 ;
71
-
72
68
await writeTransaction ((tx) async {
73
69
for (var b in batch.buckets) {
74
- count += b.data.length;
75
70
await _updateBucket2 (
76
71
tx,
77
72
jsonEncode ({
@@ -82,7 +77,6 @@ class BucketStorage {
82
77
// We get major initial sync performance improvements with IndexedDB by
83
78
// not flushing here.
84
79
}, flush: false );
85
- _compactCounter += count;
86
80
}
87
81
88
82
Future <void > _updateBucket2 (SqliteWriteContext tx, String json) async {
@@ -103,8 +97,6 @@ class BucketStorage {
103
97
['delete_bucket' , bucket]);
104
98
// No need to flush - not directly visible to the user
105
99
}, flush: false );
106
-
107
- _pendingBucketDeletes = true ;
108
100
}
109
101
110
102
Future <bool > hasCompletedSync () async {
@@ -154,8 +146,6 @@ class BucketStorage {
154
146
return SyncLocalDatabaseResult (ready: false );
155
147
}
156
148
157
- await forceCompact ();
158
-
159
149
return SyncLocalDatabaseResult (ready: true );
160
150
}
161
151
@@ -226,52 +216,6 @@ UPDATE ps_buckets SET count_since_last = 0, count_at_last = ?1->name
226
216
}
227
217
}
228
218
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
-
275
219
void setTargetCheckpoint (Checkpoint checkpoint) {
276
220
// No-op for now
277
221
}
0 commit comments