From b35b093304db9f1caa01c4ebd6437e29217671fa Mon Sep 17 00:00:00 2001 From: Tycho Bokdam Date: Mon, 21 Sep 2020 19:34:51 +0200 Subject: [PATCH] fix(graphql-api): Fixed that torrents could be added twice --- apps/graphql-api/src/shared/torrent/torrent.service.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/graphql-api/src/shared/torrent/torrent.service.ts b/apps/graphql-api/src/shared/torrent/torrent.service.ts index 6037cf3..03c502e 100755 --- a/apps/graphql-api/src/shared/torrent/torrent.service.ts +++ b/apps/graphql-api/src/shared/torrent/torrent.service.ts @@ -258,6 +258,16 @@ export class TorrentService { return resolve() } + const downloadIsAlreadyConnecting = !!this.getConnectingTorrentForDownload(download) + const downloadIsAlreadyDownloading = !!this.getTorrentForDownload(download) + + // Prevents the item from being added twice + if (downloadIsAlreadyConnecting || downloadIsAlreadyDownloading) { + this.logger.log(`[${download._id}]: Download is already going`) + + return resolve() + } + const item = await this.getItemForDownload(download) const { torrents, searchedTorrents } = item