From c0a1b7a3e0ab8ba3b1d5f17d0b309c46a2ec3479 Mon Sep 17 00:00:00 2001 From: John Furrow Date: Mon, 27 Nov 2017 22:43:57 -0800 Subject: [PATCH] When checking torrent hash, start after checking if torrent is not stopped --- server/models/ClientRequest.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/server/models/ClientRequest.js b/server/models/ClientRequest.js index 44caf82c..26f93173 100644 --- a/server/models/ClientRequest.js +++ b/server/models/ClientRequest.js @@ -185,15 +185,24 @@ class ClientRequest { checkHash(options) { const hashes = this.getEnsuredArray(options.hashes); - const hashesToStop = hashes.filter(hash => { + const stoppedHashes = hashes.filter(hash => { return torrentService.getTorrent(hash).status.includes(torrentStatusMap.stopped); }); + const hashesToStart = []; + + this.stopTorrents({ hashes }); hashes.forEach(hash => { this.requests.push(this.getMethodCall('d.check_hash', [hash])); + + if (!stoppedHashes.includes(hash)) { + hashesToStart.push(hash); + } }); - this.stopTorrents({hashes: hashesToStop}); + if (hashesToStart.length) { + this.startTorrents({ hashes: hashesToStart }); + } } createDirectory(options) {