mirror of
https://github.com/volatilityfoundation/volatility3.git
synced 2026-09-01 04:39:03 +02:00
Core: Fix up file close issue
This commit is contained in:
@@ -179,20 +179,18 @@ class ResourceAccessor(object):
|
||||
except AttributeError:
|
||||
# If our fp doesn't have an info member, carry on gracefully
|
||||
content_length = -1
|
||||
cache_file = open(temp_filename, "wb")
|
||||
|
||||
count = 0
|
||||
block = fp.read(block_size)
|
||||
while block:
|
||||
count += len(block)
|
||||
if self._progress_callback:
|
||||
self._progress_callback(
|
||||
count * 100 / max(count, int(content_length)),
|
||||
f"Reading file {url}",
|
||||
)
|
||||
cache_file.write(block)
|
||||
with open(temp_filename, "wb") as cache_file:
|
||||
count = 0
|
||||
block = fp.read(block_size)
|
||||
cache_file.close()
|
||||
while block:
|
||||
count += len(block)
|
||||
if self._progress_callback:
|
||||
self._progress_callback(
|
||||
count * 100 / max(count, int(content_length)),
|
||||
f"Reading file {url}",
|
||||
)
|
||||
cache_file.write(block)
|
||||
block = fp.read(block_size)
|
||||
else:
|
||||
vollog.debug(f"Using already cached file at: {temp_filename}")
|
||||
# Re-open the cache with a different mode
|
||||
|
||||
Reference in New Issue
Block a user