Skip to content

Commit fb56395

Browse files
mgoldenbergHywan
authored andcommitted
refactor(indexeddb): add object store for tracking time-based lock on event cache
Signed-off-by: Michael Goldenberg <[email protected]>
1 parent bc0018a commit fb56395

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

crates/matrix-sdk-indexeddb/src/event_cache_store/migrations.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ pub mod v1 {
109109

110110
pub mod keys {
111111
pub const CORE: &str = "core";
112+
pub const LEASES: &str = "leases";
113+
pub const LEASES_KEY_PATH: &str = "id";
112114
pub const ROOMS: &str = "rooms";
113115
pub const LINKED_CHUNKS: &str = "linked_chunks";
114116
pub const LINKED_CHUNKS_KEY_PATH: &str = "id";
@@ -129,19 +131,27 @@ pub mod v1 {
129131
/// Create all object stores and indices for v1 database
130132
pub fn create_object_stores(db: &IdbDatabase) -> Result<(), DomException> {
131133
create_core_object_store(db)?;
134+
create_lease_object_store(db)?;
132135
create_linked_chunks_object_store(db)?;
133136
create_events_object_store(db)?;
134137
create_gaps_object_store(db)?;
135138
Ok(())
136139
}
137140

138-
/// Create an object store for tracking miscellaneous information, e.g.,
139-
/// leases locks
141+
/// Create an object store for tracking miscellaneous information
140142
fn create_core_object_store(db: &IdbDatabase) -> Result<(), DomException> {
141143
let _ = db.create_object_store(keys::CORE)?;
142144
Ok(())
143145
}
144146

147+
/// Create an object store tracking leases on time-based locks
148+
fn create_lease_object_store(db: &IdbDatabase) -> Result<(), DomException> {
149+
let mut object_store_params = IdbObjectStoreParameters::new();
150+
object_store_params.key_path(Some(&keys::LEASES_KEY_PATH.into()));
151+
let _ = db.create_object_store_with_params(keys::LEASES, &object_store_params)?;
152+
Ok(())
153+
}
154+
145155
/// Create an object store for tracking information about linked chunks.
146156
///
147157
/// * Primary Key - `id`

0 commit comments

Comments
 (0)