From 6bc6a82df8c5bc8dffc30fecab51851ba56d9290 Mon Sep 17 00:00:00 2001 From: David Ludwig Date: Wed, 5 May 2021 23:21:14 -0500 Subject: [PATCH] Clean up torrent client API interface --- api/torrent/src/IpcClient.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/api/torrent/src/IpcClient.ts b/api/torrent/src/IpcClient.ts index 9dd27ba..d997f63 100644 --- a/api/torrent/src/IpcClient.ts +++ b/api/torrent/src/IpcClient.ts @@ -45,11 +45,22 @@ export abstract class IpcClient extends I return response.data; } + /** + * Check if the torrent client has the given torrent + */ + public async has(torrentId: string) { + let response = await this.request("has", torrentId); + if (response.error) { + console.error(response.error); + throw new Error("Failed to check if a torrent exists"); + } + return response.data; + } + /** * Get full details of each of the provided torrents - * @param torrentIds Array of torrent info hashes */ - public async details(...torrentIds: string[]) { + public async details(torrentIds: string[] = []) { let response = await this.request("details", torrentIds); if (response.error) { console.error(response.error);