delete old keys after migration

This commit is contained in:
otsmr 2026-05-13 12:43:40 +02:00
parent f45638c58d
commit 3d1b38192e

View file

@ -197,27 +197,42 @@ Future<void> runMigrations() async {
});
}
if (userService.currentUser.appVersion < 113) {
var migrationSuccess = true;
final signalIdentity = await SecureStorage.instance.read(
// ignore: deprecated_member_use_from_same_package
key: SecureStorageKeys.signalIdentity,
);
if (signalIdentity != null) {
final decoded = jsonDecode(signalIdentity);
final identity = SignalIdentity.fromJson(decoded as Map<String, dynamic>);
try {
final decoded = jsonDecode(signalIdentity);
final identity = SignalIdentity.fromJson(
decoded as Map<String, dynamic>,
);
await RustKeyManager.importSignalIdentity(
identityKeyPairStructure: identity.identityKeyPairU8List,
registrationId: identity.registrationId,
signedPreKeyStore: await getSignalSignedPreKeyStoreOld(),
);
Log.info('Importing signal identiy to the rust key manager');
// Clean up old keys after successful migration
await SecureStorage.instance.delete(
// ignore: deprecated_member_use_from_same_package
key: SecureStorageKeys.signalIdentity,
);
await SecureStorage.instance.delete(
// ignore: deprecated_member_use_from_same_package
key: SecureStorageKeys.signalSignedPreKey,
);
} catch (e) {
Log.error(e);
Log.error('Failed to migrate signal identity: $e');
migrationSuccess = false;
}
}
if (migrationSuccess) {
await UserService.update((u) {
u
..appVersion = 113
@ -230,6 +245,7 @@ Future<void> runMigrations() async {
..twonlySafeBackup?.backupId = [];
});
}
}
}
Future<void> postStartupTasks() async {