From fbedda194c2443e2916ed6451a1c6524c54d65a3 Mon Sep 17 00:00:00 2001 From: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> Date: Fri, 10 Sep 2021 11:19:45 -0500 Subject: [PATCH] Handle missing conversation in SQL migration 41 --- ts/sql/Server.ts | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/ts/sql/Server.ts b/ts/sql/Server.ts index 4e43f97f7..84ca45c5d 100644 --- a/ts/sql/Server.ts +++ b/ts/sql/Server.ts @@ -2113,15 +2113,17 @@ function updateToSchemaVersion41(currentVersion: number, db: Database) { return; } - const getConversationUuid = db.prepare( - ` - SELECT uuid - FROM - conversations - WHERE - id = $conversationId - ` - ); + const getConversationUuid = db + .prepare( + ` + SELECT uuid + FROM + conversations + WHERE + id = $conversationId + ` + ) + .pluck(); const clearSessionsAndKeys = () => { // ts/background.ts will ask user to relink so all that matters here is @@ -2250,7 +2252,7 @@ function updateToSchemaVersion41(currentVersion: number, db: Database) { let deleted = 0; for (const { id, senderId } of senderKeys) { const [conversationId] = Helpers.unencodeNumber(senderId); - const { uuid } = getConversationUuid.get({ conversationId }); + const uuid = getConversationUuid.get({ conversationId }); if (!uuid) { deleted += 1; @@ -2311,7 +2313,7 @@ function updateToSchemaVersion41(currentVersion: number, db: Database) { let updated = 0; let deleted = 0; for (const { id, conversationId } of allSessions) { - const { uuid } = getConversationUuid.get({ conversationId }); + const uuid = getConversationUuid.get({ conversationId }); if (!uuid) { deleted += 1; deleteSession.run({ id }); @@ -2359,7 +2361,7 @@ function updateToSchemaVersion41(currentVersion: number, db: Database) { let migrated = 0; for (const { id } of identityKeys) { - const { uuid } = getConversationUuid.get({ conversationId: id }); + const uuid = getConversationUuid.get({ conversationId: id }); let newId: string; if (uuid) {