Ensure we use the cache rathe rather than just saying we will.

This commit is contained in:
Mike Auty
2019-09-26 21:18:23 +01:00
parent 066a4e64f2
commit 8b3453dd29
2 changed files with 4 additions and 7 deletions
+1 -1
View File
@@ -77,7 +77,7 @@ class InvalidDataException(VolatilityException):
class SymbolSpaceError(VolatilityException):
"""Thrown when an error occurs dealing with Symbols and Symbolspaces."""
"""Thrown when an error occurs dealing with Symbolspaces and SymbolTables."""
class LayerException(VolatilityException):
+3 -6
View File
@@ -13,7 +13,7 @@ import ssl
import urllib.parse
import urllib.request
import zipfile
from typing import List, Optional
from typing import Optional
from volatility import framework
from volatility.framework import constants
@@ -49,7 +49,6 @@ class ResourceAccessor(object):
"""
self._progress_callback = progress_callback
self._context = context
self._cached_files = [] # type: List[str]
self._handlers = list(framework.class_subclasses(urllib.request.BaseHandler))
vollog.log(constants.LOGLEVEL_VVV,
"Available URL handlers: {}".format(", ".join([x.__name__ for x in self._handlers])))
@@ -71,8 +70,8 @@ class ResourceAccessor(object):
temp_filename = os.path.join(constants.CACHE_PATH,
"data_" + hashlib.sha512(bytes(url, 'latin-1')).hexdigest())
if temp_filename not in self._cached_files or not os.path.exists(temp_filename):
vollog.info("Caching file at: {}".format(temp_filename))
if not os.path.exists(temp_filename):
vollog.debug("Caching file at: {}".format(temp_filename))
try:
content_length = fp.info().get('Content-Length', -1)
@@ -92,8 +91,6 @@ class ResourceAccessor(object):
"Reading file {}".format(url))
cache_file.write(block)
cache_file.close()
# Globally stash the file as cached this python session
self._cached_files += [temp_filename]
# Re-open the cache with a different mode
curfile = open(temp_filename, mode = "rb")