From 3b4b12de0fb9316f3765293f14f5e48893d3f8fe Mon Sep 17 00:00:00 2001 From: Benjamin Harder Date: Mon, 13 May 2024 23:19:49 +0200 Subject: [PATCH] bug fix --- src/jobs/remove_slow.py | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/jobs/remove_slow.py b/src/jobs/remove_slow.py index 57996cf..b511f55 100644 --- a/src/jobs/remove_slow.py +++ b/src/jobs/remove_slow.py @@ -27,18 +27,17 @@ async def remove_slow(settingsDict, BASE_URL, API_KEY, NAME, deleted_downloads, alreadyCheckedDownloadIDs.append(queueItem['downloadId']) # One downloadId may occur in multiple queueItems - only check once for all of them per iteration if queueItem['protocol'] == 'usenet': # No need to check for speed for usenet, since there users pay for speed continue - if queueItem['sizeleft'] == 0: # Skip items that are finished downloading but are still marked as downloading. May be the case when files are moving - logger.info('>>> Detected %s download that has completed downloading - skipping check (torrent files likely in process of being moved): %s',failType, queueItem['title']) - continue - # determine if the downloaded bit on average between this and the last iteration is greater than the min threshold - downloadedSize, previousSize, increment, speed = await getDownloadedSize(settingsDict, queueItem, download_sizes_tracker, NAME) - if queueItem['status'] == 'downloading' and \ - queueItem['downloadId'] in download_sizes_tracker.dict and \ - speed is not None: - if speed < settingsDict['MIN_DOWNLOAD_SPEED']: - affectedItems.append(queueItem) - logger.debug('remove_slow/slow speed detected: %s (Speed: %d KB/s, KB now: %s, KB previous: %s, Diff: %s, In Minutes: %s', \ - queueItem['title'], speed, downloadedSize, previousSize, increment, settingsDict['REMOVE_TIMER']) + if queueItem['status'] == 'downloading': + if queueItem['sizeleft'] == 0: # Skip items that are finished downloading but are still marked as downloading. May be the case when files are moving + logger.info('>>> Detected %s download that has completed downloading - skipping check (torrent files likely in process of being moved): %s',failType, queueItem['title']) + continue + # determine if the downloaded bit on average between this and the last iteration is greater than the min threshold + downloadedSize, previousSize, increment, speed = await getDownloadedSize(settingsDict, queueItem, download_sizes_tracker, NAME) + if queueItem['downloadId'] in download_sizes_tracker.dict and speed is not None: + if speed < settingsDict['MIN_DOWNLOAD_SPEED']: + affectedItems.append(queueItem) + logger.debug('remove_slow/slow speed detected: %s (Speed: %d KB/s, KB now: %s, KB previous: %s, Diff: %s, In Minutes: %s', \ + queueItem['title'], speed, downloadedSize, previousSize, increment, settingsDict['REMOVE_TIMER']) affectedItems = await execute_checks(settingsDict, affectedItems, failType, BASE_URL, API_KEY, NAME, deleted_downloads, defective_tracker, privateDowloadIDs, protectedDownloadIDs,