mirror of
https://github.com/hydralauncher/hydra.git
synced 2026-01-23 10:51:02 +00:00
ci: testing pipeline
This commit is contained in:
17
src/main/workers/torrent-parser.worker.ts
Normal file
17
src/main/workers/torrent-parser.worker.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { parentPort } from "worker_threads";
|
||||
import parseTorrent from "parse-torrent";
|
||||
|
||||
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 torrent = await parseTorrent(buffer);
|
||||
|
||||
port.postMessage(torrent);
|
||||
});
|
||||
Reference in New Issue
Block a user