File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
crates/matrix-sdk-indexeddb/src/event_cache_store Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -20,20 +20,26 @@ use thiserror::Error;
20
20
use wasm_bindgen:: JsValue ;
21
21
use web_sys:: { DomException , IdbIndexParameters } ;
22
22
23
- const CURRENT_DB_VERSION : Version = Version :: V1 ;
23
+ /// The current version and keys used in the database.
24
+ pub mod current {
25
+ use super :: { v1, Version } ;
26
+
27
+ pub const VERSION : Version = Version :: V1 ;
28
+ pub use v1:: keys;
29
+ }
24
30
25
31
/// Opens a connection to the IndexedDB database and takes care of upgrading it
26
32
/// if necessary.
27
33
#[ allow( unused) ]
28
34
pub async fn open_and_upgrade_db ( name : & str ) -> Result < IdbDatabase , DomException > {
29
- let mut request = IdbDatabase :: open_u32 ( name, CURRENT_DB_VERSION as u32 ) ?;
35
+ let mut request = IdbDatabase :: open_u32 ( name, current :: VERSION as u32 ) ?;
30
36
request. set_on_upgrade_needed ( Some ( |event : & IdbVersionChangeEvent | -> Result < ( ) , JsValue > {
31
37
let mut version =
32
38
Version :: try_from ( event. old_version ( ) as u32 ) . map_err ( DomException :: from) ?;
33
- while version < CURRENT_DB_VERSION {
39
+ while version < current :: VERSION {
34
40
version = match version. upgrade ( event. db ( ) ) ? {
35
41
Some ( next) => next,
36
- None => CURRENT_DB_VERSION , /* No more upgrades to apply, jump forward! */
42
+ None => current :: VERSION , /* No more upgrades to apply, jump forward! */
37
43
} ;
38
44
}
39
45
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments