From 92f70fc177aad78dde9a470ebdaa486dbadc0e15 Mon Sep 17 00:00:00 2001 From: shypike Date: Sat, 1 Jun 2013 11:21:00 +0200 Subject: [PATCH] When post has just one par2-set, use full wildcard so that all files are repair and par candidates. --- sabnzbd/newsunpack.py | 10 +++++----- sabnzbd/postproc.py | 3 ++- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/sabnzbd/newsunpack.py b/sabnzbd/newsunpack.py index f156620..2fe7bac 100644 --- a/sabnzbd/newsunpack.py +++ b/sabnzbd/newsunpack.py @@ -794,7 +794,7 @@ def ZIP_Extract(zipfile, extraction_path, one_folder): # PAR2 Functions #------------------------------------------------------------------------------ -def par2_repair(parfile_nzf, nzo, workdir, setname): +def par2_repair(parfile_nzf, nzo, workdir, setname, single): """ Try to repair a set, return readd or correctness """ #set the current nzo status to "Repairing". Used in History @@ -828,7 +828,7 @@ def par2_repair(parfile_nzf, nzo, workdir, setname): joinables, zips, rars, ts = build_filelists(workdir, None, check_rar=False) finished, readd, pars, datafiles, used_joinables, used_par2 = PAR_Verify(parfile, parfile_nzf, nzo, - setname, joinables) + setname, joinables, single=single) if finished: result = True @@ -920,7 +920,7 @@ _RE_IS_MATCH_FOR = re.compile('File: "([^"]+)" - is a match for "([^"]+)"') _RE_LOADING_PAR2 = re.compile('Loading "([^"]+)"\.') _RE_LOADED_PAR2 = re.compile('Loaded (\d+) new packets') -def PAR_Verify(parfile, parfile_nzf, nzo, setname, joinables, classic=False): +def PAR_Verify(parfile, parfile_nzf, nzo, setname, joinables, classic=False, single=False): """ Run par2 on par-set """ if cfg.never_repair(): cmd = 'v' @@ -954,7 +954,7 @@ def PAR_Verify(parfile, parfile_nzf, nzo, setname, joinables, classic=False): # Append the wildcard for this set wildcard = '%s*' % os.path.join(os.path.split(parfile)[0], setname) - if len(globber(wildcard, None)) < 2: + if single or len(globber(wildcard, None)) < 2: # Support bizarre naming conventions wildcard = os.path.join(os.path.split(parfile)[0], '*') command.append(wildcard) @@ -1263,7 +1263,7 @@ def PAR_Verify(parfile, parfile_nzf, nzo, setname, joinables, classic=False): if retry_classic: logging.debug('Retry PAR2-joining with par2-classic') - return PAR_Verify(parfile, parfile_nzf, nzo, setname, joinables, classic=True) + return PAR_Verify(parfile, parfile_nzf, nzo, setname, joinables, classic=True, single=single) else: return finished, readd, pars, datafiles, used_joinables, used_par2 diff --git a/sabnzbd/postproc.py b/sabnzbd/postproc.py index c0c57c8..8bf4116 100644 --- a/sabnzbd/postproc.py +++ b/sabnzbd/postproc.py @@ -559,6 +559,7 @@ def parring(nzo, workdir): re_add = False par_error = False + single = len(repair_sets) == 1 if repair_sets: for setname in repair_sets: @@ -569,7 +570,7 @@ def parring(nzo, workdir): parfile_nzf = par_table[setname] if not os.path.exists(os.path.join(nzo.downpath, parfile_nzf.filename)): continue - need_re_add, res = par2_repair(parfile_nzf, nzo, workdir, setname) + need_re_add, res = par2_repair(parfile_nzf, nzo, workdir, setname, single=single) re_add = re_add or need_re_add if not res and not need_re_add and cfg.sfv_check(): res = try_sfv_check(nzo, workdir, setname)