feat: adding dexie

This commit is contained in:
Chubby Granny Chaser
2024-09-22 17:43:05 +01:00
parent ddd6ff7dbe
commit f860439fb5
25 changed files with 311 additions and 345 deletions

View File

@@ -1,6 +1,6 @@
import { downloadSourceSchema } from "@main/events/helpers/validators";
import { DownloadSourceStatus } from "@shared";
import type { DownloadSource, GameRepack } from "@types";
import type { DownloadSource } from "@types";
import axios, { AxiosError, AxiosHeaders } from "axios";
import { z } from "zod";
@@ -49,23 +49,11 @@ export const getUpdatedRepacks = async (downloadSources: DownloadSource[]) => {
return results;
};
export const validateDownloadSource = async ({
url,
repacks,
}: {
url: string;
repacks: GameRepack[];
}) => {
export const validateDownloadSource = async (url: string) => {
const response = await axios.get(url);
const source = downloadSourceSchema.parse(response.data);
const existingUris = source.downloads
.flatMap((download) => download.uris)
.filter((uri) => repacks.some((repack) => repack.magnet === uri));
return {
name: source.name,
downloadCount: source.downloads.length - existingUris.length,
...downloadSourceSchema.parse(response.data),
etag: response.headers["etag"],
};
};

View File

@@ -1,6 +1,6 @@
import path from "node:path";
import steamGamesWorkerPath from "./steam-games.worker?modulePath";
import downloadSourceWorkerPath from "./download-source.worker?modulePath";
import downloadSourcesWorkerPath from "./download-sources.worker?modulePath";
import Piscina from "piscina";
@@ -14,6 +14,6 @@ export const steamGamesWorker = new Piscina({
maxThreads: 1,
});
export const downloadSourceWorker = new Piscina({
filename: downloadSourceWorkerPath,
export const downloadSourcesWorker = new Piscina({
filename: downloadSourcesWorkerPath,
});