From 916e85f79e3075bb3c8b02b5788599b1f7b57e61 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Fri, 2 Feb 2024 14:03:10 +0000 Subject: [PATCH] indexeddb: Clear the object store before deleting it Since my investigation found that it significantly speeds up deletion of a store on both Firefox and Chromium if you clear() it first, do that in our migration code. --- crates/matrix-sdk-indexeddb/src/crypto_store/migrations.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/matrix-sdk-indexeddb/src/crypto_store/migrations.rs b/crates/matrix-sdk-indexeddb/src/crypto_store/migrations.rs index 8e889e841f4..e2ba8c7bb12 100644 --- a/crates/matrix-sdk-indexeddb/src/crypto_store/migrations.rs +++ b/crates/matrix-sdk-indexeddb/src/crypto_store/migrations.rs @@ -317,6 +317,11 @@ async fn prepare_data_for_v7(serializer: &IndexeddbSerializer, db: &IdbDatabase) } } + // We have finished with the old store. Clear it, since it is faster to + // clear+delete than just delete. See https://www.artificialworlds.net/blog/2024/02/01/deleting-an-indexed-db-store-can-be-incredibly-slow-on-firefox/ + // for more details. + old_store.clear()?.await?; + Ok(txn.await.into_result()?) }