Browse Source

The 'addlocalfile' API function failed to do proper category handling.

Cause is an error in the functions upload.upload_file and upload.add_local.
They added explicit attributes from the default category, while they should be adding no attributes at all.
tags/0.6.0
ShyPike 14 years ago
parent
commit
f77fe3ccd6
  1. 14
      sabnzbd/utils/upload.py

14
sabnzbd/utils/upload.py

@ -24,7 +24,7 @@ import urllib
import logging import logging
import os import os
import sabnzbd.cfg as cfg import sabnzbd.cfg as cfg
from sabnzbd.misc import get_ext, get_filename, cat_to_opts from sabnzbd.misc import get_ext, get_filename
from sabnzbd.dirscanner import ProcessArchiveFile, ProcessSingleFile from sabnzbd.dirscanner import ProcessArchiveFile, ProcessSingleFile
@ -32,8 +32,7 @@ def upload_file(url, fp):
""" Function for uploading nzbs to a running sabnzbd instance """ """ Function for uploading nzbs to a running sabnzbd instance """
try: try:
fp = urllib.quote_plus(fp) fp = urllib.quote_plus(fp)
cat, pp, script, priority = cat_to_opts(None) url = '%s&mode=addlocalfile&name=%s' % (url, fp)
url = '%s&mode=addlocalfile&name=%s&pp=%s&script=%s&priority=%s' % (url, fp, pp, script, priority)
# Add local apikey if it wasn't already in the registered URL # Add local apikey if it wasn't already in the registered URL
apikey = cfg.api_key() apikey = cfg.api_key()
if apikey and 'apikey' not in url: if apikey and 'apikey' not in url:
@ -44,7 +43,7 @@ def upload_file(url, fp):
password = cfg.password() password = cfg.password()
if username and password: if username and password:
url = '%s&ma_username=%s&ma_password=%s' % (url, username, password) url = '%s&ma_username=%s&ma_password=%s' % (url, username, password)
u = urllib2.urlopen(url) urllib2.urlopen(url)
except: except:
logging.error("Failed to upload file: %s", fp) logging.error("Failed to upload file: %s", fp)
logging.info("Traceback: ", exc_info = True) logging.info("Traceback: ", exc_info = True)
@ -55,11 +54,10 @@ def add_local(f):
if os.path.exists(f): if os.path.exists(f):
fn = get_filename(f) fn = get_filename(f)
if fn: if fn:
cat, pp, script, priority = cat_to_opts(None) if get_ext(fn) in ('.zip', '.rar', '.gz'):
if get_ext(fn) in ('.zip','.rar', '.gz'): ProcessArchiveFile(fn, f, keep=True)
ProcessArchiveFile(fn, f, pp=pp, script=script, priority=priority, keep=True)
elif get_ext(fn) in ('.nzb'): elif get_ext(fn) in ('.nzb'):
ProcessSingleFile(fn, f, pp=pp, script=script, priority=priority, keep=True) ProcessSingleFile(fn, f, keep=True)
else: else:
logging.error("Filename not found: %s", f) logging.error("Filename not found: %s", f)
else: else:

Loading…
Cancel
Save