@@ -14,11 +14,9 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
17
- import { LocalStorageCryptoStore , IndexedDBStore , IndexedDBCryptoStore } from "matrix-js-sdk/src/matrix" ;
17
+ import { IndexedDBStore , IndexedDBCryptoStore } from "matrix-js-sdk/src/matrix" ;
18
18
import { logger } from "matrix-js-sdk/src/logger" ;
19
19
20
- import SettingsStore from "../settings/SettingsStore" ;
21
- import { Features } from "../settings/Settings" ;
22
20
import { getIDBFactory } from "./StorageAccess" ;
23
21
24
22
const localStorage = window . localStorage ;
@@ -141,55 +139,34 @@ async function checkSyncStore(): Promise<StoreCheck> {
141
139
}
142
140
143
141
async function checkCryptoStore ( ) : Promise < StoreCheck > {
144
- if ( await SettingsStore . getValue ( Features . RustCrypto ) ) {
145
- // check first if there is a rust crypto store
146
- try {
147
- const rustDbExists = await IndexedDBCryptoStore . exists ( getIDBFactory ( ) ! , RUST_CRYPTO_STORE_NAME ) ;
148
- log ( `Rust Crypto store using IndexedDB contains data? ${ rustDbExists } ` ) ;
149
-
150
- if ( rustDbExists ) {
151
- // There was an existing rust database, so consider it healthy.
152
- return { exists : true , healthy : true } ;
153
- } else {
154
- // No rust store, so let's check if there is a legacy store not yet migrated.
155
- try {
156
- const legacyIdbExists = await IndexedDBCryptoStore . existsAndIsNotMigrated (
157
- getIDBFactory ( ) ! ,
158
- LEGACY_CRYPTO_STORE_NAME ,
159
- ) ;
160
- log ( `Legacy Crypto store using IndexedDB contains non migrated data? ${ legacyIdbExists } ` ) ;
161
- return { exists : legacyIdbExists , healthy : true } ;
162
- } catch ( e ) {
163
- error ( "Legacy crypto store using IndexedDB inaccessible" , e ) ;
164
- }
165
-
166
- // No need to check local storage or memory as rust stack doesn't support them.
167
- // Given that rust stack requires indexeddb, set healthy to false.
168
- return { exists : false , healthy : false } ;
142
+ // check first if there is a rust crypto store
143
+ try {
144
+ const rustDbExists = await IndexedDBCryptoStore . exists ( getIDBFactory ( ) ! , RUST_CRYPTO_STORE_NAME ) ;
145
+ log ( `Rust Crypto store using IndexedDB contains data? ${ rustDbExists } ` ) ;
146
+
147
+ if ( rustDbExists ) {
148
+ // There was an existing rust database, so consider it healthy.
149
+ return { exists : true , healthy : true } ;
150
+ } else {
151
+ // No rust store, so let's check if there is a legacy store not yet migrated.
152
+ try {
153
+ const legacyIdbExists = await IndexedDBCryptoStore . existsAndIsNotMigrated (
154
+ getIDBFactory ( ) ! ,
155
+ LEGACY_CRYPTO_STORE_NAME ,
156
+ ) ;
157
+ log ( `Legacy Crypto store using IndexedDB contains non migrated data? ${ legacyIdbExists } ` ) ;
158
+ return { exists : legacyIdbExists , healthy : true } ;
159
+ } catch ( e ) {
160
+ error ( "Legacy crypto store using IndexedDB inaccessible" , e ) ;
169
161
}
170
- } catch ( e ) {
171
- error ( "Rust crypto store using IndexedDB inaccessible" , e ) ;
162
+
163
+ // No need to check local storage or memory as rust stack doesn't support them.
164
+ // Given that rust stack requires indexeddb, set healthy to false.
172
165
return { exists : false , healthy : false } ;
173
166
}
174
- } else {
175
- let exists = false ;
176
- // legacy checks
177
- try {
178
- exists = await IndexedDBCryptoStore . exists ( getIDBFactory ( ) ! , LEGACY_CRYPTO_STORE_NAME ) ;
179
- log ( `Crypto store using IndexedDB contains data? ${ exists } ` ) ;
180
- return { exists, healthy : true } ;
181
- } catch ( e ) {
182
- error ( "Crypto store using IndexedDB inaccessible" , e ) ;
183
- }
184
- try {
185
- exists = LocalStorageCryptoStore . exists ( localStorage ) ;
186
- log ( `Crypto store using local storage contains data? ${ exists } ` ) ;
187
- return { exists, healthy : true } ;
188
- } catch ( e ) {
189
- error ( "Crypto store using local storage inaccessible" , e ) ;
190
- }
191
- log ( "Crypto store using memory only" ) ;
192
- return { exists, healthy : false } ;
167
+ } catch ( e ) {
168
+ error ( "Rust crypto store using IndexedDB inaccessible" , e ) ;
169
+ return { exists : false , healthy : false } ;
193
170
}
194
171
}
195
172
0 commit comments