mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-24 19:31:03 +00:00
feat: adding dexie
This commit is contained in:
@@ -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"],
|
||||
};
|
||||
};
|
||||
@@ -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,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user