Skip to content

Commit b2b1b4e

Browse files
authoredFeb 18, 2025··
fix: constant initialization of content tables (#3146)
1 parent c351947 commit b2b1b4e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

‎src/runtime/internal/database.server.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ export async function checkAndImportDatabaseIntegrity(event: H3Event, collection
6363
async function _checkAndImportDatabaseIntegrity(event: H3Event, collection: string, integrityVersion: string, config: RuntimeConfig['content']) {
6464
const db = loadDatabaseAdapter(config)
6565

66-
const before: { version: string, ready: boolean } | null = await db.first<{ version: string, ready: boolean }>(`select * from ${tables.info} where id = ?`, [`checksum_${collection}`]).catch((): null => null)
66+
const before = await db.first<{ version: string, ready: boolean }>(`select * from ${tables.info} where id = ?`, [`checksum_${collection}`]).catch((): null => null)
6767

6868
if (before?.version) {
69-
if (before.ready === true && before.version === integrityVersion) {
69+
if (before.version === integrityVersion) {
70+
if (before.ready) {
7071
// table is already initialized and ready, use it
71-
return true
72-
}
72+
return true
73+
}
7374

74-
if (before.ready === false && before.version === integrityVersion) {
7575
// if another request has already started the initialization of
7676
// this version of this collection, wait for it to finish
7777
// then respond that the database is ready

0 commit comments

Comments
 (0)
Please sign in to comment.