Merge pull request #1535 from famedly/nico/fix-okb-reset

Make online key backup reset actually backup keys
This commit is contained in:
Nicolas Werner 2023-08-01 08:24:25 +00:00 committed by GitHub
commit b27fd4575d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View File

@ -182,8 +182,6 @@ class KeyManager {
if (uploaded) { if (uploaded) {
await client.database await client.database
?.markInboundGroupSessionAsUploaded(roomId, sessionId); ?.markInboundGroupSessionAsUploaded(roomId, sessionId);
} else {
_haveKeysToUpload = true;
} }
}); });
final room = client.getRoomById(roomId); final room = client.getRoomById(roomId);
@ -750,7 +748,6 @@ class KeyManager {
} }
bool _isUploadingKeys = false; bool _isUploadingKeys = false;
bool _haveKeysToUpload = true;
Future<void> backgroundTasks() async { Future<void> backgroundTasks() async {
final database = client.database; final database = client.database;
@ -760,12 +757,11 @@ class KeyManager {
} }
_isUploadingKeys = true; _isUploadingKeys = true;
try { try {
if (!_haveKeysToUpload || !(await isCached())) { if (!(await isCached())) {
return; // we can't backup anyways return; // we can't backup anyways
} }
final dbSessions = await database.getInboundGroupSessionsToUpload(); final dbSessions = await database.getInboundGroupSessionsToUpload();
if (dbSessions.isEmpty) { if (dbSessions.isEmpty) {
_haveKeysToUpload = false;
return; // nothing to do return; // nothing to do
} }
final privateKey = final privateKey =

View File

@ -584,6 +584,8 @@ class Bootstrap {
Logs().v( Logs().v(
'And finally set all megolm keys as needing to be uploaded again...'); 'And finally set all megolm keys as needing to be uploaded again...');
await client.database?.markInboundGroupSessionsAsNeedingUpload(); await client.database?.markInboundGroupSessionsAsNeedingUpload();
Logs().v('And uploading keys...');
await client.encryption?.keyManager.backgroundTasks();
} catch (e, s) { } catch (e, s) {
Logs().e('[Bootstrapping] Error setting up online key backup', e, s); Logs().e('[Bootstrapping] Error setting up online key backup', e, s);
state = BootstrapState.error; state = BootstrapState.error;