From 24af888139fb3364abffb81a8a94e87f2ec109ca Mon Sep 17 00:00:00 2001 From: Christian Paul <christianp@matrix.org> Date: Fri, 8 Jan 2021 15:59:22 +0100 Subject: [PATCH] Add debugging of countEntries() --- src/db/roomstore.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/db/roomstore.ts b/src/db/roomstore.ts index 158a96a..e344e33 100644 --- a/src/db/roomstore.ts +++ b/src/db/roomstore.ts @@ -103,15 +103,20 @@ export class DbRoomStore { * Matrix room and a remote room counts as one pair. * @returns {number} The amount of room pairs as an integer */ - public async countEntries() { + public async countEntries(): Promise<number> { const row = (await this.db.Get("SELECT COUNT(*) AS count FROM room_entries WHERE matrix_id IS NOT NULL AND remote_id IS NOT NULL")) || {}; - if (typeof row.count !== "number") { + let count = row.count; + if (typeof count === 'string') { + count = Number.parseInt(count); + } + + if (typeof count !== "number") { log.error("Failed to count room entries"); - throw Error("Failed to count room entries"); + throw Error(`Failed to count room entries ${JSON.stringify(row)} AND ${typeof count}`); } - return row.count; + return count; } public async upsertEntry(entry: IRoomStoreEntry) { -- GitLab