mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-21 01:53:57 +00:00
fix: removing repacks from worker threads to fix race condition
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
import path from "node:path";
|
||||
import steamGamesWorkerPath from "./steam-games.worker?modulePath";
|
||||
import repacksWorkerPath from "./repacks.worker?modulePath";
|
||||
import downloadSourceWorkerPath from "./download-source.worker?modulePath";
|
||||
|
||||
import Piscina from "piscina";
|
||||
@@ -14,10 +13,6 @@ export const steamGamesWorker = new Piscina({
|
||||
},
|
||||
});
|
||||
|
||||
export const repacksWorker = new Piscina({
|
||||
filename: repacksWorkerPath,
|
||||
});
|
||||
|
||||
export const downloadSourceWorker = new Piscina({
|
||||
filename: downloadSourceWorkerPath,
|
||||
});
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
import { formatName } from "@shared";
|
||||
import { CatalogueEntry, GameRepack } from "@types";
|
||||
import flexSearch from "flexsearch";
|
||||
|
||||
const repacksIndex = new flexSearch.Index();
|
||||
|
||||
const state: { repacks: GameRepack[] } = { repacks: [] };
|
||||
|
||||
export const setRepacks = (repacks: GameRepack[]) => {
|
||||
for (let i = 0; i < state.repacks.length; i++) {
|
||||
repacksIndex.remove(i);
|
||||
}
|
||||
|
||||
state.repacks = repacks;
|
||||
|
||||
for (let i = 0; i < repacks.length; i++) {
|
||||
const repack = repacks[i];
|
||||
|
||||
const formattedTitle = formatName(repack.title);
|
||||
|
||||
repacksIndex.add(i, formattedTitle);
|
||||
}
|
||||
};
|
||||
|
||||
export const search = (options: flexSearch.SearchOptions) =>
|
||||
repacksIndex
|
||||
.search({ ...options, query: formatName(options.query ?? "") })
|
||||
.map((index) => state.repacks[index]);
|
||||
|
||||
export const list = () => state.repacks;
|
||||
|
||||
export const findRepacksForCatalogueEntries = (entries: CatalogueEntry[]) => {
|
||||
return entries.map((entry) => {
|
||||
const repacks = search({ query: formatName(entry.title) });
|
||||
return { ...entry, repacks };
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user