Browse Source

Improve Prospective Par2 to handle multisets better

Now we get too many blocks, but before the second set wouldn't get enough blocks
tags/2.3.0Alpha1
Safihre 8 years ago
parent
commit
42cdba5ce3
  1. 25
      sabnzbd/nzbstuff.py

25
sabnzbd/nzbstuff.py

@ -1257,7 +1257,7 @@ class NzbObject(TryList):
""" Add parfile to the files to be downloaded """ Add parfile to the files to be downloaded
Resets trylist just to be sure Resets trylist just to be sure
""" """
if not parfile.completed and parfile not in self.files: if not parfile.completed and parfile not in self.files and parfile not in self.finished_files:
parfile.reset_all_try_lists() parfile.reset_all_try_lists()
self.files.append(parfile) self.files.append(parfile)
@ -1278,30 +1278,23 @@ class NzbObject(TryList):
@synchronized(NZO_LOCK) @synchronized(NZO_LOCK)
def prospective_add(self, nzf): def prospective_add(self, nzf):
""" Add par2 files to compensate for missing articles """ Add par2 files to compensate for missing articles
This fails in case of multi-sets with identical setnames
""" """
# How many do we already have?
blocks_already = 0
for nzf_check in self.files:
# Only par2 files have a blocks attribute
if nzf_check.blocks:
blocks_already = blocks_already + int_conv(nzf_check.blocks)
# Make sure to also select a parset if it was in the original filename # Make sure to also select a parset if it was in the original filename
original_filename = self.renames.get(nzf.filename, '') original_filename = self.renames.get(nzf.filename, '')
# Need more? # Get some blocks!
if not nzf.is_par2 and blocks_already < self.bad_articles: if not nzf.is_par2:
# We have to find the right par-set # We have to find the right par-set
blocks_new = 0
for parset in self.extrapars.keys(): for parset in self.extrapars.keys():
if (parset in nzf.filename or parset in original_filename) and self.extrapars[parset]: if (parset in nzf.filename or parset in original_filename) and self.extrapars[parset]:
for new_nzf in self.extrapars[parset]: for new_nzf in self.extrapars[parset]:
# Already downloaded? self.add_parfile(new_nzf)
if not new_nzf.completed: blocks_new += int_conv(new_nzf.blocks)
self.add_parfile(new_nzf)
blocks_already = blocks_already + int_conv(new_nzf.blocks)
logging.info('Prospectively added %s repair blocks to %s', new_nzf.blocks, self.final_name)
# Enough now? # Enough now?
if blocks_already >= self.bad_articles: if blocks_new >= self.bad_articles:
logging.info('Prospectively added %s repair blocks to %s', blocks_new, self.final_name)
break break
# Reset NZO TryList # Reset NZO TryList
self.reset_try_list() self.reset_try_list()

Loading…
Cancel
Save