From 9c8056030ced7d5c2f4caaaf9d978e6b6f061c39 Mon Sep 17 00:00:00 2001 From: Andy Balaam Date: Tue, 6 Aug 2024 13:32:54 +0100 Subject: [PATCH] fixup: remove unneeded InboundGroupSessionIndexedDbObject3 --- .../src/crypto_store/migrations/mod.rs | 1 - .../src/crypto_store/migrations/v10.rs | 59 ------------------- .../src/crypto_store/migrations/v8_to_v10.rs | 9 +-- 3 files changed, 5 insertions(+), 64 deletions(-) delete mode 100644 crates/matrix-sdk-indexeddb/src/crypto_store/migrations/v10.rs diff --git a/crates/matrix-sdk-indexeddb/src/crypto_store/migrations/mod.rs b/crates/matrix-sdk-indexeddb/src/crypto_store/migrations/mod.rs index 37cd62a4e73..99b019f63c6 100644 --- a/crates/matrix-sdk-indexeddb/src/crypto_store/migrations/mod.rs +++ b/crates/matrix-sdk-indexeddb/src/crypto_store/migrations/mod.rs @@ -25,7 +25,6 @@ use crate::{ mod old_keys; mod v0_to_v5; -mod v10; mod v10_to_v11; mod v11_to_v12; mod v5_to_v7; diff --git a/crates/matrix-sdk-indexeddb/src/crypto_store/migrations/v10.rs b/crates/matrix-sdk-indexeddb/src/crypto_store/migrations/v10.rs deleted file mode 100644 index 86a579dc402..00000000000 --- a/crates/matrix-sdk-indexeddb/src/crypto_store/migrations/v10.rs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright 2024 The Matrix.org Foundation C.I.C. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -//! Structs and keys used for reading/writing objects in schema v10 - -use crate::crypto_store::indexeddb_serializer::MaybeEncrypted; - -/// The objects we store in the inbound_group_sessions3 indexeddb object -/// store (in schema v10) -#[derive(serde::Serialize, serde::Deserialize)] -pub struct InboundGroupSessionIndexedDbObject3 { - /// Possibly encrypted - /// [`matrix_sdk_crypto::olm::group_sessions::PickledInboundGroupSession`] - pickled_session: MaybeEncrypted, - - /// Whether the session data has yet to be backed up. - /// - /// Since we only need to be able to find entries where this is `true`, we - /// skip serialization in cases where it is `false`. That has the effect - /// of omitting it from the indexeddb index. - /// - /// We also use a custom serializer because bools can't be used as keys in - /// indexeddb. - #[serde( - default, - skip_serializing_if = "std::ops::Not::not", - with = "crate::serialize_bool_for_indexeddb" - )] - needs_backup: bool, - - /// Unused: for future compatibility. In future, will contain the order - /// number (not the ID!) of the backup for which this key has been - /// backed up. This will replace `needs_backup`, fixing the performance - /// problem identified in - /// https://github.com/element-hq/element-web/issues/26892 - /// because we won't need to update all records when we spot a new backup - /// version. - /// In this version of the code, this is always set to -1, meaning: - /// "refer to the `needs_backup` property". See: - /// https://github.com/element-hq/element-web/issues/26892#issuecomment-1906336076 - backed_up_to: i32, -} - -impl InboundGroupSessionIndexedDbObject3 { - pub fn new(pickled_session: MaybeEncrypted, needs_backup: bool) -> Self { - Self { pickled_session, needs_backup, backed_up_to: -1 } - } -} diff --git a/crates/matrix-sdk-indexeddb/src/crypto_store/migrations/v8_to_v10.rs b/crates/matrix-sdk-indexeddb/src/crypto_store/migrations/v8_to_v10.rs index c457904d1bd..04ffb0b0762 100644 --- a/crates/matrix-sdk-indexeddb/src/crypto_store/migrations/v8_to_v10.rs +++ b/crates/matrix-sdk-indexeddb/src/crypto_store/migrations/v8_to_v10.rs @@ -26,10 +26,9 @@ use crate::{ keys, migrations::{ add_nonunique_index, do_schema_upgrade, old_keys, - v10::InboundGroupSessionIndexedDbObject3, v7::InboundGroupSessionIndexedDbObject2, - MigrationDb, + v7::InboundGroupSessionIndexedDbObject2, MigrationDb, }, - Result, + InboundGroupSessionIndexedDbObject, Result, }, IndexeddbCryptoStoreError, }; @@ -101,9 +100,11 @@ pub(crate) async fn data_migrate(name: &str, serializer: &IndexeddbSerializer) - // Serialize the session in the new format // This is much the same as [`IndexeddbStore::serialize_inbound_group_session`]. - let new_value = InboundGroupSessionIndexedDbObject3::new( + let new_value = InboundGroupSessionIndexedDbObject::new( serializer.maybe_encrypt_value(session.pickle().await)?, !session.backed_up(), + None, + None, ); // Write it to the new store