mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-02-24 23:06:37 +00:00
33 lines
947 B
TypeScript
33 lines
947 B
TypeScript
import path from "node:path";
|
|
import { app } from "electron";
|
|
|
|
import { chunk } from "lodash-es";
|
|
|
|
import { createDataSource } from "@main/data-source";
|
|
import { Repack } from "@main/entity";
|
|
import { repackRepository } from "@main/repository";
|
|
|
|
export const resolveDatabaseUpdates = async () => {
|
|
const updateDataSource = createDataSource({
|
|
database: app.isPackaged
|
|
? path.join(process.resourcesPath, "hydra.db")
|
|
: path.join(__dirname, "..", "..", "hydra.db"),
|
|
});
|
|
|
|
return updateDataSource.initialize().then(async () => {
|
|
const updateRepackRepository = updateDataSource.getRepository(Repack);
|
|
|
|
const updateRepacks = await updateRepackRepository.find();
|
|
|
|
const updateRepacksChunks = chunk(updateRepacks, 800);
|
|
|
|
for (const chunk of updateRepacksChunks) {
|
|
await repackRepository
|
|
.createQueryBuilder()
|
|
.insert()
|
|
.values(chunk)
|
|
.orIgnore()
|
|
.execute();
|
|
}
|
|
});
|
|
};
|