diff --git a/server/scripts/sync-database/sync-database.ts b/server/scripts/sync-database/sync-database.ts index ad5c428c3..c83e46d68 100644 --- a/server/scripts/sync-database/sync-database.ts +++ b/server/scripts/sync-database/sync-database.ts @@ -12,6 +12,7 @@ import { ICollection } from "monk"; import os from "os"; import path from "path"; import { ChartDocument, FolderDocument, SongDocument, TableDocument } from "tachi-common"; +import { InitaliseFolderChartLookup } from "utils/folder"; interface SyncInstructions { pattern: RegExp; @@ -147,6 +148,7 @@ const syncInstructions: SyncInstructions[] = [ if (bwriteOps.length) { await collection.bulkWrite(bwriteOps); + await InitaliseFolderChartLookup(); } }, }, diff --git a/server/src/main.ts b/server/src/main.ts index 916ece53a..8ce69c246 100644 --- a/server/src/main.ts +++ b/server/src/main.ts @@ -8,6 +8,7 @@ import CreateLogCtx from "lib/logger/logger"; import { Environment, ServerConfig, ServerTypeInfo } from "lib/setup/config"; import path from "path"; import server from "server/server"; +import { InitaliseFolderChartLookup } from "utils/folder"; import { FormatVersion } from "./lib/constants/version"; const logger = CreateLogCtx(__filename); @@ -30,6 +31,13 @@ db.users.indexes().then((r) => { } }); +db["folder-chart-lookup"].findOne().then((r) => { + // If there are no folder chart lookups, initialise them. + if (!r) { + InitaliseFolderChartLookup(); + } +}); + if (ServerConfig.ENABLE_SERVER_HTTPS) { logger.warn( "HTTPS Mode is enabled. This should not be used in production, and you should instead run behind a reverse proxy."