Queue stalls permanently if unable to create _UNPACK_ directories in v0.4.6

Report & discuss bugs found in SABnzbd
Forum rules
Help us help you:
  • Are you using the latest stable version of SABnzbd? Downloads page.
  • Tell us what system you run SABnzbd on.
  • Adhere to the forum rules.
  • Do you experience problems during downloading?
    Check your connection in Status and Interface settings window.
    Use Test Server in Config > Servers.
    We will probably ask you to do a test using only basic settings.
  • Do you experience problems during repair or unpacking?
    Enable +Debug logging in the Status and Interface settings window and share the relevant parts of the log here using [ code ] sections.
Post Reply
WhiteSea
Newbie
Newbie
Posts: 1
Joined: November 3rd, 2008, 11:10 am

Queue stalls permanently if unable to create _UNPACK_ directories in v0.4.6

Post by WhiteSea »

I found an issue on my Linux system where the queue will stall and start to back up if SABnzbd is unable to create the _UNPACK_ directory due to illegal characters. In my case this was a "?".

It would appear that only filenames are sanitised and not the directory structure. I have applied the following quick fix in misc.py and have added sanitize_dirname immediately following sanitise_pathname. I have also highlighted in red the single change required in CreateAllDirs.

This is just a quick fix and I have not gone through the code in any great depth, as no doubt you will want to revise this and incorporate into a future release.

Regards,
Craig.

################################################################################
# sanitize_dirname                                                            #
################################################################################
def sanitize_dirname(name):
    """ Return pathname with illegal chars converted to legal ones
    """
    illegal = r'\/?*:;|"'
    legal   = r'++{}!@--#`'

    repl = sabnzbd.REPLACE_ILLEGAL
    lst = []
    for ch in name.strip():
        if ch in illegal:
            if repl:
                ch = legal[illegal.find(ch)]
                lst.append(ch)
        else:
            lst.append(ch)
    name = ''.join(lst)

    if not name:
        name = 'unknown'

    return name

################################################################################
# DirPermissions                                                               #
################################################################################
def CreateAllDirs(path, umask=None):
    """ Create all required path elements and set umask on all
        Return True if last elelent could be made or exists """
    result = True
    if os.name == 'nt':
        try:
            os.makedirs(path)
        except:
            result = False
    else:
        list = []
        list.extend(path.split('/'))
        path = ''
        for d in list:
            if d:
                path += '/' + sanitize_dirname(d)
   
             if not os.path.exists(path):
                    try:
                        os.mkdir(path)
                        result = True
                    except:
                        result = False
                try:
                    if umask: os.chmod(path, int(umask, 8) | 0700)
                except:
                    pass
    return result
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Queue stalls permanently if unable to create _UNPACK_ directories in v0.4.6

Post by shypike »

Odd, the only folder name that's created comes from either the NZB name
or the description in an RSS feed.
Both of these are filtered.
Can you give an example of how this odd folder name entered SABnzbd?
Please email to [email protected]
User avatar
shypike
Administrator
Administrator
Posts: 19774
Joined: January 18th, 2008, 12:49 pm

Re: Queue stalls permanently if unable to create _UNPACK_ directories in v0.4.6

Post by shypike »

Received your info.
The question that remains is: how did you enter this NZB file into SABnzbd?
It cannot have been a locally stored file. Did you get it from an RSS feed?
If so, can you send me the URL?
User avatar
switch
Moderator
Moderator
Posts: 1380
Joined: January 17th, 2008, 3:55 pm
Location: UK

Re: Queue stalls permanently if unable to create _UNPACK_ directories in v0.4.6

Post by switch »

I had a chat with WhiteSea earlier and resolved the issue, see http://trac2.assembla.com/SABnzbd/changeset/2202
Post Reply