feat: adding background to item

This commit is contained in:
Hydra 2024-05-03 19:51:13 +01:00
parent f6072eeb5c
commit 1f2f269736
No known key found for this signature in database
20 changed files with 77 additions and 98 deletions

View file

@ -1,16 +1,12 @@
import { parentPort } from "worker_threads";
import parseTorrent from "parse-torrent";
import { getFileBuffer } from "@main/helpers";
const port = parentPort;
if (!port) throw new Error("IllegalState");
const getTorrentBuffer = (url: string) =>
fetch(url, { method: "GET" }).then((response) =>
response.arrayBuffer().then((buffer) => Buffer.from(buffer))
);
port.on("message", async (url: string) => {
const buffer = await getTorrentBuffer(url);
const buffer = await getFileBuffer(url);
const torrent = await parseTorrent(buffer);
port.postMessage(torrent);