Reduce amount of logging in 41st migration
This commit is contained in:
parent
f65c25b7d8
commit
e50f76a909
1 changed files with 16 additions and 13 deletions
|
@ -79,23 +79,23 @@ export default function updateToSchemaVersion41(
|
||||||
return aStats.active_at - bStats.active_at;
|
return aStats.active_at - bStats.active_at;
|
||||||
};
|
};
|
||||||
|
|
||||||
const clearSessionsAndKeys = () => {
|
const clearSessionsAndKeys = (): number => {
|
||||||
// ts/background.ts will ask user to relink so all that matters here is
|
// ts/background.ts will ask user to relink so all that matters here is
|
||||||
// to maintain an invariant:
|
// to maintain an invariant:
|
||||||
//
|
//
|
||||||
// After this migration all sessions and keys are prefixed by
|
// After this migration all sessions and keys are prefixed by
|
||||||
// "uuid:".
|
// "uuid:".
|
||||||
db.exec(
|
const keyCount = [
|
||||||
`
|
db.prepare('DELETE FROM senderKeys').run().changes,
|
||||||
DELETE FROM senderKeys;
|
db.prepare('DELETE FROM sessions').run().changes,
|
||||||
DELETE FROM sessions;
|
db.prepare('DELETE FROM signedPreKeys').run().changes,
|
||||||
DELETE FROM signedPreKeys;
|
db.prepare('DELETE FROM preKeys').run().changes,
|
||||||
DELETE FROM preKeys;
|
].reduce((a: number, b: number): number => a + b);
|
||||||
`
|
|
||||||
);
|
|
||||||
|
|
||||||
assertSync(removeById<string>(db, 'items', 'identityKey'));
|
assertSync(removeById<string>(db, 'items', 'identityKey'));
|
||||||
assertSync(removeById<string>(db, 'items', 'registrationId'));
|
assertSync(removeById<string>(db, 'items', 'registrationId'));
|
||||||
|
|
||||||
|
return keyCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
const moveIdentityKeyToMap = (ourUuid: string) => {
|
const moveIdentityKeyToMap = (ourUuid: string) => {
|
||||||
|
@ -422,11 +422,14 @@ export default function updateToSchemaVersion41(
|
||||||
const ourUuid = getOurUuid(db);
|
const ourUuid = getOurUuid(db);
|
||||||
|
|
||||||
if (!isValidUuid(ourUuid)) {
|
if (!isValidUuid(ourUuid)) {
|
||||||
logger.error(
|
const deleteCount = clearSessionsAndKeys();
|
||||||
'updateToSchemaVersion41: no uuid is available clearing sessions'
|
|
||||||
);
|
|
||||||
|
|
||||||
clearSessionsAndKeys();
|
if (deleteCount > 0) {
|
||||||
|
logger.error(
|
||||||
|
'updateToSchemaVersion41: no uuid is available, ' +
|
||||||
|
`erased ${deleteCount} sessions/keys`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
db.pragma('user_version = 41');
|
db.pragma('user_version = 41');
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue