mirror of
https://github.com/sabnzbd/sabnzbd.git
synced 2026-06-07 07:16:34 -04:00
Do a more thorough check when a bad try_list is detected (#2330)
* Do a more thorough check when a bad try_list is detected * Improve idle job check and fix DNS lookup problem * Loop through copy of article list and move nzf.reset_try_list below the article check Closes #2320
This commit is contained in:
@@ -230,6 +230,7 @@ class Server:
|
||||
self.info = get_server_addrinfo(self.host, self.port)
|
||||
if not self.info:
|
||||
self.bad_cons += self.threads
|
||||
self.info = False
|
||||
else:
|
||||
self.bad_cons = 0
|
||||
self.request = False
|
||||
|
||||
@@ -883,9 +883,14 @@ class NzbQueue:
|
||||
def stop_idle_jobs(self):
|
||||
"""Detect jobs that have zero files left and send them to post processing"""
|
||||
# Only check servers that are active
|
||||
nr_servers = len([server for server in sabnzbd.Downloader.servers[:] if server.active])
|
||||
active_servers = [server for server in sabnzbd.Downloader.servers[:] if server.active]
|
||||
nr_servers = len(active_servers)
|
||||
empty = []
|
||||
|
||||
if nr_servers <= 0:
|
||||
logging.debug("Skipping stop_idle_jobs because no servers are active")
|
||||
return
|
||||
|
||||
for nzo in self.__nzo_list:
|
||||
if not nzo.futuretype and not nzo.files and nzo.status not in (Status.PAUSED, Status.GRABBING):
|
||||
logging.info("Found idle job %s", nzo.final_name)
|
||||
@@ -896,8 +901,16 @@ class NzbQueue:
|
||||
if len(nzo.try_list) >= nr_servers:
|
||||
# Maybe the NZF's need a reset too?
|
||||
for nzf in nzo.files:
|
||||
if nzo.removed_from_queue:
|
||||
break
|
||||
|
||||
if len(nzf.try_list) >= nr_servers:
|
||||
# We do not want to reset all article trylists, they are good
|
||||
# Check for articles where all active servers have already been tried
|
||||
for article in nzf.articles[:]:
|
||||
if article.all_servers_in_try_list(active_servers):
|
||||
sabnzbd.NzbQueue.register_article(article, success=False)
|
||||
nzo.increase_bad_articles_counter("missing_articles")
|
||||
|
||||
logging.info("Resetting bad trylist for file %s in job %s", nzf.filename, nzo.final_name)
|
||||
nzf.reset_try_list()
|
||||
|
||||
|
||||
@@ -112,11 +112,19 @@ class TryList:
|
||||
def __init__(self):
|
||||
self.try_list: List[Server] = []
|
||||
|
||||
def server_in_try_list(self, server: Server):
|
||||
def server_in_try_list(self, server: Server) -> bool:
|
||||
"""Return whether specified server has been tried"""
|
||||
with TRYLIST_LOCK:
|
||||
return server in self.try_list
|
||||
|
||||
def all_servers_in_try_list(self, servers: List[Server]) -> bool:
|
||||
"""Check if all servers have been tried"""
|
||||
with TRYLIST_LOCK:
|
||||
for server in servers:
|
||||
if not server in self.try_list:
|
||||
return False
|
||||
return True
|
||||
|
||||
def add_to_try_list(self, server: Server):
|
||||
"""Register server as having been tried already"""
|
||||
with TRYLIST_LOCK:
|
||||
|
||||
Reference in New Issue
Block a user