diff --git a/server/src/lib/database-seeds/repo.ts b/server/src/lib/database-seeds/repo.ts index f7b554128..00d33950a 100644 --- a/server/src/lib/database-seeds/repo.ts +++ b/server/src/lib/database-seeds/repo.ts @@ -310,18 +310,16 @@ export async function BacksyncCollection( collection: ICollection, commitMessage: string ) { - for (const branch of ["main"]) { - const repo = await PullDatabaseSeeds(undefined, branch); + const repo = await PullDatabaseSeeds(undefined); - let charts = await collection.find({}); + let charts = await collection.find({}); - await repo.WriteCollection(collectionName, charts); + await repo.WriteCollection(collectionName, charts); - // @ts-expect-error Force node to free the memory. - charts = null; + // @ts-expect-error Force node to free the memory. + charts = null; - await repo.CommitChangesBack(`${commitMessage} ${new Date().toISOString()}`); + await repo.CommitChangesBack(`${commitMessage} ${new Date().toISOString()}`); - await repo.Destroy(); - } + await repo.Destroy(); } diff --git a/server/src/lib/setup/config.ts b/server/src/lib/setup/config.ts index e54167164..da1222361 100644 --- a/server/src/lib/setup/config.ts +++ b/server/src/lib/setup/config.ts @@ -88,6 +88,7 @@ export interface TachiServerConfig { REPO_URL: string; USER_NAME: string | null; USER_EMAIL: string | null; + BRANCH?: string; }; EMAIL_CONFIG?: { FROM: string; @@ -231,6 +232,7 @@ const err = p(config, { REPO_URL: "string", USER_NAME: "?string", USER_EMAIL: "?string", + BRANCH: "*string", }), }); diff --git a/server/src/scripts/sync-database.ts b/server/src/scripts/sync-database.ts index 9bc5e71d6..2d0c08123 100644 --- a/server/src/scripts/sync-database.ts +++ b/server/src/scripts/sync-database.ts @@ -7,7 +7,7 @@ import fjsh from "fast-json-stable-hash"; import { PullDatabaseSeeds } from "lib/database-seeds/repo"; import CreateLogCtx from "lib/logger/logger"; import UpdateIsPrimaryStatus from "lib/score-mutation/update-isprimary"; -import { TachiConfig } from "lib/setup/config"; +import { ServerConfig, TachiConfig } from "lib/setup/config"; import { RemoveStaleFolderShowcaseStats } from "lib/showcase/showcase"; import { UpdateQuestSubscriptions } from "lib/targets/quests"; import { RecalcAllScores } from "utils/calculations/recalc-scores"; @@ -357,7 +357,10 @@ async function SynchroniseDBWithSeeds() { // Wait for mongo to connect first. await monkDB.then(() => void 0); - const databaseSeedsRepo = await PullDatabaseSeeds(options.localPath); + const databaseSeedsRepo = await PullDatabaseSeeds( + options.localPath, + ServerConfig.SEEDS_CONFIG?.BRANCH + ); for await (const { collectionName, data } of databaseSeedsRepo.IterateCollections()) { const spawnLogger = CreateLogCtx(`${collectionName} Sync`);