mirror of
https://github.com/zkldi/Tachi.git
synced 2026-10-01 11:28:13 +03:00
feat: enforce branches with seeds (#1064)
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
}),
|
||||
});
|
||||
|
||||
|
||||
@@ -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`);
|
||||
|
||||
Reference in New Issue
Block a user