mirror of
https://github.com/hydralauncher/hydra.git
synced 2025-03-09 15:40:26 +00:00
feat: adding background to item
This commit is contained in:
parent
f6072eeb5c
commit
1f2f269736
20 changed files with 77 additions and 98 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue