Пример #1
0
def update_filelist(nzbid):
    # If a lock already exists in updating the cache file, bail out.
    if nzb.lock_exists(LOCK_FILELIST):
        return

    # Get the list of files from cache and from disk.
    nzb.lock_create(LOCK_FILELIST)

    try:
        cache_filepath = get_cache_filepath(nzbid)
        directory = nzb.get_nzb_directory()

        if not os.path.isdir(directory):
            nzb.log_warning('Directory %s does not appear valid.' % directory)

        filelist = nzb.get_new_files(os.listdir(directory), cache_filepath)

        # Cache the files that we've found that we just processed.
        with open(cache_filepath, 'a') as cachefile:
            for filename in filelist:
                name, extension = os.path.splitext(filename)
                if extension != '.tmp':
                    cachefile.write(filename + '\n')
                    process_download(directory, filename)
            cachefile.close()
    except Exception as e:
        traceback.print_exc()
        nzb.log_error(e)
        raise
    finally:
        nzb.lock_release(LOCK_FILELIST)
Пример #2
0
def update_filelist(nzbid):
    # If a lock already exists in updating the cache file, bail out.
    if nzb.lock_exists(LOCK_FILELIST):
        return

    # Get the list of files from cache and from disk.
    nzb.lock_create(LOCK_FILELIST)

    try:
        cache_filepath = get_cache_filepath(nzbid)
        directory = nzb.get_nzb_directory()

        if not os.path.isdir(directory):
            nzb.log_warning('Directory %s does not appear valid.' % directory)

        filelist = nzb.get_new_files(os.listdir(directory), cache_filepath)

        # Cache the files that we've found that we just processed.
        with open(cache_filepath, 'a') as cachefile:
            for filename in filelist:
                name, extension = os.path.splitext(filename)
                if extension != '.tmp':
                    cachefile.write(filename + '\n')
                    process_download(directory, filename)
            cachefile.close()
    except Exception as e:
        traceback.print_exc()
        nzb.log_error(e)
        raise
    finally:
        nzb.lock_release(LOCK_FILELIST)
Пример #3
0
def process_download(directory, filename):
    if not os.path.isdir(directory):
        nzb.log_warning('Directory %s does not appear valid.' % directory)

    filepath = os.path.join(directory, filename)
    cache_filepath = get_cache_filepath('%s-contents' % nzb.get_nzb_id())
    contentlist = nzb.get_rar_filelist(filepath)
    filelist = nzb.get_new_files(contentlist, cache_filepath)

    with open(cache_filepath, 'a') as cachefile:
        for file in filelist:
            inspect_rar_content(directory, file)
            cachefile.write(file + '\n')
        cachefile.close()
Пример #4
0
def process_download(directory, filename):
    if not os.path.isdir(directory):
        nzb.log_warning('Directory %s does not appear valid.' % directory)

    filepath = os.path.join(directory, filename)
    cache_filepath = get_cache_filepath('%s-contents' % nzb.get_nzb_id())
    contentlist = nzb.get_rar_filelist(filepath)
    filelist = nzb.get_new_files(contentlist, cache_filepath)

    with open(cache_filepath, 'a') as cachefile:
        for file in filelist:
            inspect_rar_content(directory, file)
            cachefile.write(file + '\n')
        cachefile.close()