fix: Do not logout before migration
Before the migration of the databases starts there is always a logout signal sent. This was wrong. This also cleans up the logs a little bit and removes the useless parameters for the second init() call because those are going to come from the new database anyway.
This commit is contained in:
parent
967712adfe
commit
fe06b96e93
|
|
@ -876,18 +876,12 @@ class Client extends MatrixApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (accessToken == null || homeserver == null || _userID == null) {
|
if (accessToken == null || homeserver == null || _userID == null) {
|
||||||
// we aren't logged in
|
|
||||||
encryption?.dispose();
|
|
||||||
encryption = null;
|
|
||||||
onLoginStateChanged.add(LoginState.loggedOut);
|
|
||||||
Logs().i('User is not logged in.');
|
|
||||||
_initLock = false;
|
|
||||||
if (legacyDatabaseBuilder != null) {
|
if (legacyDatabaseBuilder != null) {
|
||||||
Logs().i('Check legacy database for migration data');
|
Logs().i('Check legacy database for migration data...');
|
||||||
final legacyDatabase = await legacyDatabaseBuilder(this);
|
final legacyDatabase = await legacyDatabaseBuilder(this);
|
||||||
final migrateClient = await legacyDatabase.getClient(clientName);
|
final migrateClient = await legacyDatabase.getClient(clientName);
|
||||||
if (migrateClient != null) {
|
if (migrateClient != null) {
|
||||||
Logs().i('Found data in the legacy database');
|
Logs().i('Found data in the legacy database!');
|
||||||
_id = migrateClient['client_id'];
|
_id = migrateClient['client_id'];
|
||||||
await database.insertClient(
|
await database.insertClient(
|
||||||
clientName,
|
clientName,
|
||||||
|
|
@ -900,9 +894,9 @@ class Client extends MatrixApi {
|
||||||
migrateClient['olm_account'],
|
migrateClient['olm_account'],
|
||||||
);
|
);
|
||||||
for (final type in cacheTypes) {
|
for (final type in cacheTypes) {
|
||||||
Logs().i('Migrate $type');
|
|
||||||
final ssssCache = await legacyDatabase.getSSSSCache(_id, type);
|
final ssssCache = await legacyDatabase.getSSSSCache(_id, type);
|
||||||
if (ssssCache != null) {
|
if (ssssCache != null) {
|
||||||
|
Logs().d('Migrate $type');
|
||||||
await database.storeSSSSCache(
|
await database.storeSSSSCache(
|
||||||
_id,
|
_id,
|
||||||
type,
|
type,
|
||||||
|
|
@ -918,16 +912,15 @@ class Client extends MatrixApi {
|
||||||
}
|
}
|
||||||
await legacyDatabase.close();
|
await legacyDatabase.close();
|
||||||
if (migrateClient != null) {
|
if (migrateClient != null) {
|
||||||
return init(
|
return init();
|
||||||
newToken: migrateClient['token'],
|
|
||||||
newHomeserver: Uri.parse(migrateClient['homeserver_url']),
|
|
||||||
newUserID: migrateClient['user_id'],
|
|
||||||
newDeviceID: migrateClient['device_id'],
|
|
||||||
newDeviceName: migrateClient['device_name'],
|
|
||||||
newOlmAccount: migrateClient['olm_account'],
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// we aren't logged in
|
||||||
|
encryption?.dispose();
|
||||||
|
encryption = null;
|
||||||
|
onLoginStateChanged.add(LoginState.loggedOut);
|
||||||
|
Logs().i('User is not logged in.');
|
||||||
|
_initLock = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
_initLock = false;
|
_initLock = false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue