Make sync-database safe for bms and usc.

This commit is contained in:
zkldi
2021-11-26 15:18:01 +00:00
parent ccf74c1a0e
commit cf487114b5
+18 -2
View File
@@ -104,8 +104,24 @@ async function GenericUpsert<T>(
const syncInstructions: SyncInstructions[] = [
{
pattern: /^charts-(usc|bms)$/u,
handler: (charts: ChartDocument[], collection: ICollection<ChartDocument>, logger) =>
GenericUpsert(charts, collection, "chartID", logger, false),
handler: async (
charts: ChartDocument[],
collection: ICollection<ChartDocument>,
logger
) => {
// Since the USC and BMS databases are managed Bokutachi-side, we
// shouldn't be honoring any sort of updates from tachi-database-seeds
// aside from an initial one.
const isInitial = await collection.findOne();
if (isInitial) {
const r = await GenericUpsert(charts, collection, "chartID", logger, true);
if (r) {
await InitaliseFolderChartLookup();
}
}
},
},
{
pattern: /^charts-/u,