@@ -103,26 +103,12 @@ export class SqliteBucketStorage extends BaseObserver<BucketStorageListener> imp
103103 * Mark a bucket for deletion.
104104 */
105105 private async deleteBucket ( bucket : string ) {
106- // Delete a bucket, but allow it to be re-created.
107- // To achieve this, we rename the bucket to a new temp name, and change all ops to remove.
108- // By itself, this new bucket would ensure that the previous objects are deleted if they contain no more references.
109- // If the old bucket is re-added, this new bucket would have no effect.
110106 await this . writeTransaction ( async ( tx ) => {
111- const { uuid } = await tx . get < { uuid : string } > ( 'select uuid() as uuid' ) ;
112- const newName = `$delete_${ bucket } _${ uuid } ` ;
113- this . logger . debug ( 'Deleting bucket' , bucket ) ;
114107 await tx . execute (
115- `UPDATE ps_oplog SET op=${ OpTypeEnum . REMOVE } , data=NULL WHERE op=${ OpTypeEnum . PUT } AND superseded=0 AND bucket=?` ,
116- [ bucket ]
117- ) ;
118- // Rename bucket
119- await tx . execute ( 'UPDATE ps_oplog SET bucket=? WHERE bucket=?' , [ newName , bucket ] ) ;
120- await tx . execute ( 'DELETE FROM ps_buckets WHERE name = ?' , [ bucket ] ) ;
121- await tx . execute (
122- 'INSERT INTO ps_buckets(name, pending_delete, last_op) SELECT ?, 1, IFNULL(MAX(op_id), 0) FROM ps_oplog WHERE bucket = ?' ,
123- [ newName , newName ]
124- ) ;
108+ 'INSERT INTO powersync_operations(op, data) VALUES(?, ?)' ,
109+ [ 'delete_bucket' , bucket ] ) ;
125110 } ) ;
111+
126112 this . logger . debug ( 'done deleting bucket' ) ;
127113 this . pendingBucketDeletes = true ;
128114 }
0 commit comments