fix TB free free active item logic
Some checks failed
Deploy Addon / build (SSH_HOST_2, SSH_KEY_2) (push) Has been cancelled
Deploy Addon / build (SSH_HOST_3, SSH_KEY_3) (push) Has been cancelled
Deploy Addon / build (SSH_HOST_4, SSH_KEY_4) (push) Has been cancelled

This commit is contained in:
TheBeastLT 2024-11-29 11:16:51 +02:00
parent 01f5ebd90f
commit d8ddec1638

View file

@ -151,8 +151,9 @@ async function freeLastActiveTorrent(apiKey) {
if (seedingTorrent) {
return controlTorrent(apiKey, seedingTorrent.id, 'stop_seeding');
}
if (torrents.filter(statusDownloading).pop()) {
return controlTorrent(apiKey, seedingTorrent.id, 'delete');
const downloadingTorrent = torrents.filter(statusDownloading).pop();
if (downloadingTorrent) {
return controlTorrent(apiKey, downloadingTorrent.id, 'delete');
}
return Promise.reject({ detail: 'No torrent to pause found' });
}