Browse Source

Only run recover_par2_names if all_ok

tags/3.4.0Beta2
Safihre 4 years ago
parent
commit
fc721f31c5
  1. 27
      sabnzbd/postproc.py

27
sabnzbd/postproc.py

@ -65,7 +65,7 @@ from sabnzbd.filesystem import (
get_filename, get_filename,
) )
from sabnzbd.nzbstuff import NzbObject from sabnzbd.nzbstuff import NzbObject
from sabnzbd.sorting import Sorter, is_sample, move_to_parent_directory from sabnzbd.sorting import Sorter, is_sample
from sabnzbd.constants import ( from sabnzbd.constants import (
REPAIR_PRIORITY, REPAIR_PRIORITY,
FORCE_PRIORITY, FORCE_PRIORITY,
@ -80,7 +80,6 @@ import sabnzbd.emailer as emailer
import sabnzbd.downloader import sabnzbd.downloader
import sabnzbd.config as config import sabnzbd.config as config
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
import sabnzbd.encoding as encoding
import sabnzbd.nzbqueue import sabnzbd.nzbqueue
import sabnzbd.database as database import sabnzbd.database as database
import sabnzbd.notifier as notifier import sabnzbd.notifier as notifier
@ -317,6 +316,8 @@ def process_job(nzo: NzbObject):
# Signal empty download, for when 'empty_postproc' is enabled # Signal empty download, for when 'empty_postproc' is enabled
empty = False empty = False
nzb_list = [] nzb_list = []
one_folder = False
newfiles = []
# These need to be initialized in case of a crash # These need to be initialized in case of a crash
workdir_complete = "" workdir_complete = ""
script_log = "" script_log = ""
@ -419,7 +420,6 @@ def process_job(nzo: NzbObject):
nzo nzo
) )
newfiles = []
# Run Stage 2: Unpack # Run Stage 2: Unpack
if flag_unpack: if flag_unpack:
# Set the current nzo status to "Extracting...". Used in History # Set the current nzo status to "Extracting...". Used in History
@ -480,6 +480,7 @@ def process_job(nzo: NzbObject):
script_output = "" script_output = ""
script_ret = 0 script_ret = 0
script_error = False
if not nzb_list: if not nzb_list:
# Give destination its final name # Give destination its final name
if cfg.folder_rename() and tmp_workdir_complete and not one_folder: if cfg.folder_rename() and tmp_workdir_complete and not one_folder:
@ -513,22 +514,23 @@ def process_job(nzo: NzbObject):
if newfiles: if newfiles:
workdir_complete, ok = file_sorter.rename(newfiles, workdir_complete) workdir_complete, ok = file_sorter.rename(newfiles, workdir_complete)
if not ok: if not ok:
workdir_complete, ok = move_to_parent_directory(workdir_complete)
nzo.set_unpack_info("Unpack", T("Failed to move files")) nzo.set_unpack_info("Unpack", T("Failed to move files"))
all_ok = False all_ok = False
# Run further post-processing
if (all_ok or not cfg.safe_postproc()) and not nzb_list:
# Use par2 files to deobfuscate unpacked file names # Use par2 files to deobfuscate unpacked file names
if cfg.process_unpacked_par2(): if cfg.process_unpacked_par2():
newfiles = deobfuscate.recover_par2_names(newfiles) newfiles = deobfuscate.recover_par2_names(newfiles)
if cfg.deobfuscate_final_filenames() and all_ok and not nzb_list: if cfg.deobfuscate_final_filenames():
# Deobfuscate the filenames # Deobfuscate the filenames
logging.info("Running deobfuscate") logging.info("Running deobfuscate")
deobfuscate.deobfuscate_list(newfiles, nzo.final_name) deobfuscate.deobfuscate_list(newfiles, nzo.final_name)
# Run the user script # Run the user script
script_path = make_script_path(script) script_path = make_script_path(script)
if (all_ok or not cfg.safe_postproc()) and (not nzb_list) and script_path: if script_path:
# Set the current nzo status to "Ext Script...". Used in History # Set the current nzo status to "Ext Script...". Used in History
nzo.status = Status.RUNNING nzo.status = Status.RUNNING
nzo.set_action_line(T("Running script"), script) nzo.set_action_line(T("Running script"), script)
@ -543,22 +545,16 @@ def process_job(nzo: NzbObject):
nzo.set_unpack_info("Script", script_line, unique=True) nzo.set_unpack_info("Script", script_line, unique=True)
else: else:
nzo.set_unpack_info("Script", T("Ran %s") % script, unique=True) nzo.set_unpack_info("Script", T("Ran %s") % script, unique=True)
else:
script = ""
script_line = ""
script_ret = 0
# Maybe bad script result should fail job # Maybe bad script result should fail job
if script_ret and cfg.script_can_fail(): if script_ret and cfg.script_can_fail():
script_error = True script_error = True
all_ok = False all_ok = False
nzo.fail_msg = T("Script exit code is %s") % script_ret nzo.fail_msg = T("Script exit code is %s") % script_ret
else:
script_error = False
# Email the results # Email the results
if (not nzb_list) and cfg.email_endjob(): if not nzb_list and cfg.email_endjob():
if (cfg.email_endjob() == 1) or (cfg.email_endjob() == 2 and (unpack_error or par_error or script_error)): if cfg.email_endjob() == 1 or (cfg.email_endjob() == 2 and (unpack_error or par_error or script_error)):
emailer.endjob( emailer.endjob(
nzo.final_name, nzo.final_name,
nzo.cat, nzo.cat,
@ -581,8 +577,7 @@ def process_job(nzo: NzbObject):
if len(script_log.rstrip().split("\n")) > 1: if len(script_log.rstrip().split("\n")) > 1:
nzo.set_unpack_info( nzo.set_unpack_info(
"Script", "Script",
'%s%s <a href="./scriptlog?name=%s">(%s)</a>' '%s%s <a href="./scriptlog?name=%s">(%s)</a>' % (script_ret, script_line, script_output, T("More")),
% (script_ret, script_line, encoding.xml_name(script_output), T("More")),
unique=True, unique=True,
) )
else: else:

Loading…
Cancel
Save