Skip to content

Commit 0d5048d

Browse files
committed
refactor(indexeddb): remove transaction arg from do_schema_upgrade() callback in crypto store
Signed-off-by: Michael Goldenberg <[email protected]>
1 parent 621b9ed commit 0d5048d

File tree

9 files changed

+14
-15
lines changed

9 files changed

+14
-15
lines changed

crates/matrix-sdk-indexeddb/src/crypto_store/migrations/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,13 +200,12 @@ type OldVersion = u32;
200200
/// * `name` - name of the indexeddb database to be upgraded.
201201
/// * `version` - version we are upgrading to.
202202
/// * `f` - closure which will be called if the database is below the version
203-
/// given. It will be called with three arguments `(db, txn, oldver)`, where:
203+
/// given. It will be called with two arguments `(db, oldver)`, where:
204204
/// * `db` - the [`IdbDatabase`]
205-
/// * `txn` - the database transaction: a [`IdbTransaction`]
206205
/// * `oldver` - the version number before the upgrade.
207206
async fn do_schema_upgrade<F>(name: &str, version: u32, f: F) -> Result<(), DomException>
208207
where
209-
F: Fn(&IdbDatabase, IdbTransaction<'_>, OldVersion) -> Result<(), JsValue> + 'static,
208+
F: Fn(&IdbDatabase, OldVersion) -> Result<(), JsValue> + 'static,
210209
{
211210
info!("IndexeddbCryptoStore upgrade schema -> v{version} starting");
212211
let mut db_req: OpenDbRequest = IdbDatabase::open_u32(name, version)?;
@@ -218,7 +217,7 @@ where
218217
let old_version = evt.old_version() as u32;
219218

220219
// Run the upgrade code we were supplied
221-
f(evt.db(), evt.transaction(), old_version)
220+
f(evt.db(), old_version)
222221
}));
223222

224223
let db = db_req.await?;

crates/matrix-sdk-indexeddb/src/crypto_store/migrations/v0_to_v5.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use crate::crypto_store::{
2626

2727
/// Perform schema migrations as needed, up to schema version 5.
2828
pub(crate) async fn schema_add(name: &str) -> Result<(), DomException> {
29-
do_schema_upgrade(name, 5, |db, _, old_version| {
29+
do_schema_upgrade(name, 5, |db, old_version| {
3030
// An old_version of 1 could either mean actually the first version of the
3131
// schema, or a completely empty schema that has been created with a
3232
// call to `IdbDatabase::open` with no explicit "version". So, to determine

crates/matrix-sdk-indexeddb/src/crypto_store/migrations/v10_to_v11.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,5 @@ pub(crate) async fn data_migrate(
5959
pub(crate) async fn schema_bump(name: &str) -> crate::crypto_store::Result<(), DomException> {
6060
// Just bump the version number to 11 to demonstrate that we have run the data
6161
// changes from data_migrate.
62-
do_schema_upgrade(name, 11, |_, _, _| Ok(())).await
62+
do_schema_upgrade(name, 11, |_, _| Ok(())).await
6363
}

crates/matrix-sdk-indexeddb/src/crypto_store/migrations/v11_to_v12.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ use crate::crypto_store::{migrations::do_schema_upgrade, Result};
1818

1919
/// Perform the schema upgrade v11 to v12, just bumping the schema version
2020
pub(crate) async fn schema_bump(name: &str) -> Result<(), DomException> {
21-
do_schema_upgrade(name, 12, |_, _, _| Ok(())).await
21+
do_schema_upgrade(name, 12, |_, _| Ok(())).await
2222
}

crates/matrix-sdk-indexeddb/src/crypto_store/migrations/v12_to_v13.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::crypto_store::{keys, migrations::do_schema_upgrade, Result};
2121
/// Perform the schema upgrade v12 to v13, adding the
2222
/// `received_room_key_bundles` store.
2323
pub(crate) async fn schema_add(name: &str) -> Result<(), DomException> {
24-
do_schema_upgrade(name, 13, |db, _, _| {
24+
do_schema_upgrade(name, 13, |db, _| {
2525
db.create_object_store(keys::RECEIVED_ROOM_KEY_BUNDLES)?;
2626
Ok(())
2727
})

crates/matrix-sdk-indexeddb/src/crypto_store/migrations/v13_to_v15.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ use crate::{
3030
/// This creates an identical object store to `inbound_group_sessions3`, but
3131
/// adds index on `(curve_key, sender_data_type, session_id)`.
3232
pub(crate) async fn schema_add(name: &str) -> Result<(), DomException> {
33-
do_schema_upgrade(name, 14, |db, _, _| {
33+
do_schema_upgrade(name, 14, |db, _| {
3434
let object_store = db.create_object_store(keys::INBOUND_GROUP_SESSIONS_V4)?;
3535
v8_to_v10::index_add(&object_store)?;
3636
object_store.create_index(
@@ -104,7 +104,7 @@ pub(crate) async fn data_migrate(name: &str, serializer: &IndexeddbSerializer) -
104104

105105
/// Perform the schema upgrade v14 to v15, deleting `inbound_group_sessions3`.
106106
pub(crate) async fn schema_delete(name: &str) -> Result<(), DomException> {
107-
do_schema_upgrade(name, 15, |db, _, _| {
107+
do_schema_upgrade(name, 15, |db, _| {
108108
db.delete_object_store(old_keys::INBOUND_GROUP_SESSIONS_V3)?;
109109
Ok(())
110110
})

crates/matrix-sdk-indexeddb/src/crypto_store/migrations/v5_to_v7.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ use crate::{
3636

3737
/// Perform the schema upgrade v5 to v6, creating `inbound_group_sessions2`.
3838
pub(crate) async fn schema_add(name: &str) -> Result<(), DomException> {
39-
do_schema_upgrade(name, 6, |db, _, _| {
39+
do_schema_upgrade(name, 6, |db, _| {
4040
let object_store = db.create_object_store(old_keys::INBOUND_GROUP_SESSIONS_V2)?;
4141

4242
add_nonunique_index(
@@ -109,7 +109,7 @@ pub(crate) async fn data_migrate(name: &str, serializer: &IndexeddbSerializer) -
109109

110110
/// Perform the schema upgrade v6 to v7, deleting `inbound_group_sessions`.
111111
pub(crate) async fn schema_delete(name: &str) -> Result<(), DomException> {
112-
do_schema_upgrade(name, 7, |db, _, _| {
112+
do_schema_upgrade(name, 7, |db, _| {
113113
db.delete_object_store(old_keys::INBOUND_GROUP_SESSIONS_V1)?;
114114
Ok(())
115115
})

crates/matrix-sdk-indexeddb/src/crypto_store/migrations/v7_to_v8.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ pub(crate) async fn data_migrate(name: &str, serializer: &IndexeddbSerializer) -
116116

117117
/// Perform the schema upgrade v7 to v8, Just bumping the schema version.
118118
pub(crate) async fn schema_bump(name: &str) -> Result<(), DomException> {
119-
do_schema_upgrade(name, 8, |_, _, _| {
119+
do_schema_upgrade(name, 8, |_, _| {
120120
// Just bump the version number to 8 to demonstrate that we have run the data
121121
// changes from prepare_data_for_v8.
122122
Ok(())

crates/matrix-sdk-indexeddb/src/crypto_store/migrations/v8_to_v10.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub(crate) fn index_add(object_store: &IdbObjectStore<'_>) -> Result<(), DomExce
5050

5151
/// Perform the schema upgrade v8 to v9, creating `inbound_group_sessions3`.
5252
pub(crate) async fn schema_add(name: &str) -> Result<(), DomException> {
53-
do_schema_upgrade(name, 9, |db, _, _| {
53+
do_schema_upgrade(name, 9, |db, _| {
5454
let object_store = db.create_object_store(old_keys::INBOUND_GROUP_SESSIONS_V3)?;
5555
index_add(&object_store)?;
5656
Ok(())
@@ -128,7 +128,7 @@ pub(crate) async fn data_migrate(name: &str, serializer: &IndexeddbSerializer) -
128128

129129
/// Perform the schema upgrade v8 to v10, deleting `inbound_group_sessions2`.
130130
pub(crate) async fn schema_delete(name: &str) -> Result<(), DomException> {
131-
do_schema_upgrade(name, 10, |db, _, _| {
131+
do_schema_upgrade(name, 10, |db, _| {
132132
db.delete_object_store(old_keys::INBOUND_GROUP_SESSIONS_V2)?;
133133
Ok(())
134134
})

0 commit comments

Comments
 (0)