Exemple #1
0
def load_files_from_cache(layer):
    '''Given a layer object, populate file level information'''
    loaded = False
    raw_file_list = cache.get_files(layer.fs_hash)
    if raw_file_list:
        logger.debug('Loading files from cache: layer \"%s\"',
                     layer.fs_hash[:10])
        for file_dict in raw_file_list:
            f = FileData(file_dict['name'], file_dict['path'])
            f.fill(file_dict)
            # collect file origins
            if 'origins' in file_dict.keys():
                for origin_dict in file_dict['origins']:
                    for notice in origin_dict['notices']:
                        f.origins.add_notice_to_origins(
                            origin_dict['origin_str'],
                            Notice(notice['message'], notice['level']))
            layer.add_file(f)
            loaded = True
    else:
        # if there are no files, generate them from the pre-calculated
        # hash file
        logger.debug('Reading files in filesystem...')
        layer.add_files()
    return loaded
Exemple #2
0
def load_files_from_cache(layer):
    '''Given a layer object, populate file level information'''
    raw_file_list = cache.get_files(layer.fs_hash)
    if raw_file_list:
        logger.debug('Loading files from cache: layer \"%s\"',
                     layer.fs_hash[:10])
        for file_dict in raw_file_list:
            f = FileData(file_dict['name'], file_dict['path'])
            f.fill(file_dict)
            # collect file origins
            if 'origins' in file_dict.keys():
                for origin_dict in file_dict['origins']:
                    for notice in origin_dict['notices']:
                        f.origins.add_notice_to_origins(
                            origin_dict['origin_str'],
                            Notice(notice['message'], notice['level']))
            layer.add_file(f)