1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-25 05:23:13 +03:00

Use js-sdk logger in rust sdk (#4918)

This commit is contained in:
Richard van der Hoff
2025-07-25 10:57:25 +01:00
committed by GitHub
parent 61e07633df
commit 812d0aaef6
3 changed files with 17 additions and 18 deletions

View File

@@ -98,19 +98,16 @@ export async function initRustCrypto(args: {
logger.debug("Initialising Rust crypto-sdk WASM artifact");
await RustSdkCryptoJs.initAsync();
// enable tracing in the rust-sdk
new RustSdkCryptoJs.Tracing(RustSdkCryptoJs.LoggerLevel.Debug).turnOn();
logger.debug("Opening Rust CryptoStore");
let storeHandle;
if (args.storePrefix) {
if (args.storeKey) {
storeHandle = await StoreHandle.openWithKey(args.storePrefix, args.storeKey);
storeHandle = await StoreHandle.openWithKey(args.storePrefix, args.storeKey, logger);
} else {
storeHandle = await StoreHandle.open(args.storePrefix, args.storePassphrase);
storeHandle = await StoreHandle.open(args.storePrefix, args.storePassphrase, logger);
}
} else {
storeHandle = await StoreHandle.open();
storeHandle = await StoreHandle.open(null, null, logger);
}
if (args.legacyCryptoStore) {
@@ -155,6 +152,7 @@ async function initOlmMachine(
new RustSdkCryptoJs.UserId(userId),
new RustSdkCryptoJs.DeviceId(deviceId),
storeHandle,
logger,
);
// A final migration step, now that we have an OlmMachine.

View File

@@ -80,9 +80,6 @@ export async function migrateFromLegacyCrypto(args: {
// initialise the rust matrix-sdk-crypto-wasm, if it hasn't already been done
await RustSdkCryptoJs.initAsync();
// enable tracing in the rust-sdk
new RustSdkCryptoJs.Tracing(RustSdkCryptoJs.LoggerLevel.Debug).turnOn();
if (!(await legacyStore.containsData())) {
// This store was never used. Nothing to migrate.
return;
@@ -230,7 +227,7 @@ async function migrateBaseData(
pickleKey,
"user_signing",
);
await RustSdkCryptoJs.Migration.migrateBaseData(migrationData, pickleKey, storeHandle);
await RustSdkCryptoJs.Migration.migrateBaseData(migrationData, pickleKey, storeHandle, logger);
}
async function countOlmSessions(logger: Logger, legacyStore: CryptoStore): Promise<number> {
@@ -269,7 +266,7 @@ async function migrateOlmSessions(
migrationData.push(pickledSession);
}
await RustSdkCryptoJs.Migration.migrateOlmSessions(migrationData, pickleKey, storeHandle);
await RustSdkCryptoJs.Migration.migrateOlmSessions(migrationData, pickleKey, storeHandle, logger);
await legacyStore.deleteEndToEndSessionsBatch(batch);
onBatchDone(batch.length);
}
@@ -343,7 +340,7 @@ async function migrateMegolmSessions(
migrationData.push(pickledSession);
}
await RustSdkCryptoJs.Migration.migrateMegolmSessions(migrationData, pickleKey, storeHandle);
await RustSdkCryptoJs.Migration.migrateMegolmSessions(migrationData, pickleKey, storeHandle, logger);
await legacyStore.deleteEndToEndInboundGroupSessionsBatch(batch);
onBatchDone(batch.length);
}