Beispiel #1
0
def load_from_cache(layer, redo=False):
    '''Given a layer object, check against cache to see if that layer id exists
    if yes then load any relevant layer level information. The default
    operation is to not redo the cache. Add notices to the layer's origins
    matching the origin_str'''
    loaded = False
    if not redo:
        # check if the layer has been cached
        if layer.fs_hash in cache.get_layers():
            layer.files_analyzed = cache.cache.get(layer.fs_hash).get(
                'files_analyzed', False)
            layer.os_guess = cache.cache.get(layer.fs_hash).get('os_guess', '')
            layer.pkg_format = cache.cache.get(layer.fs_hash).get(
                'pkg_format', '')
            layer.extension_info = cache.cache.get(layer.fs_hash).get(
                'extension_info', {})
            load_packages_from_cache(layer)
            load_files_from_cache(layer)
            load_notices_from_cache(layer)
            loaded = True
        else:
            # if the hash is not present in the cache, load that data from the
            # hash file
            logger.debug('Reading files in filesystem...')
            layer.add_files()
    return loaded
Beispiel #2
0
def load_from_cache(layer, redo=False):
    '''Given a layer object, check against cache to see if that layer id exists
    if yes then load any relevant layer level information. The default
    operation is to not redo the cache. Add notices to the layer's origins
    matching the origin_str'''
    loaded = False
    if not redo:
        # check if packages are available in the cache
        if load_packages_from_cache(layer):
            loaded = True
        # load some extra properties into the layer if available
        if layer.fs_hash in cache.get_layers():
            layer.files_analyzed = cache.cache[layer.fs_hash]['files_analyzed']
            layer.os_guess = cache.cache[layer.fs_hash]['os_guess']
            layer.pkg_format = cache.cache[layer.fs_hash]['pkg_format']
        load_files_from_cache(layer)
    return loaded