Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 983c719

Browse files
committed
Remove support for legacy crypto stack in StorageManager
We're not going to use the legacy stack any more.
1 parent 38f1098 commit 983c719

File tree

1 file changed

+26
-49
lines changed

1 file changed

+26
-49
lines changed

src/utils/StorageManager.ts

Lines changed: 26 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,9 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import { LocalStorageCryptoStore, IndexedDBStore, IndexedDBCryptoStore } from "matrix-js-sdk/src/matrix";
17+
import { IndexedDBStore, IndexedDBCryptoStore } from "matrix-js-sdk/src/matrix";
1818
import { logger } from "matrix-js-sdk/src/logger";
1919

20-
import SettingsStore from "../settings/SettingsStore";
21-
import { Features } from "../settings/Settings";
2220
import { getIDBFactory } from "./StorageAccess";
2321

2422
const localStorage = window.localStorage;
@@ -141,55 +139,34 @@ async function checkSyncStore(): Promise<StoreCheck> {
141139
}
142140

143141
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);
169161
}
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.
172165
return { exists: false, healthy: false };
173166
}
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 };
193170
}
194171
}
195172

0 commit comments

Comments
 (0)