Skip to content

Commit dd06faa

Browse files
committed
Add user cache directory as fallback for downloaded symbols
1 parent 98e2f7a commit dd06faa

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

volatility3/framework/constants/__init__.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@
2525

2626
REQUIRED_PYTHON_VERSION = (3, 8, 0)
2727

28+
CACHE_PATH = os.path.join(
29+
os.environ.get("XDG_CACHE_HOME") or os.path.join(os.path.expanduser("~"), ".cache"),
30+
"volatility3",
31+
)
32+
"""Default path to store cached data"""
33+
34+
if sys.platform == "win32":
35+
CACHE_PATH = os.path.realpath(
36+
os.path.join(os.environ.get("APPDATA", os.path.expanduser("~")), "volatility3")
37+
)
38+
os.makedirs(CACHE_PATH, exist_ok=True)
39+
2840
PLUGINS_PATH = [
2941
os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "plugins")),
3042
os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "plugins")),
@@ -34,6 +46,9 @@
3446
SYMBOL_BASEPATHS = [
3547
os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "..", "symbols")),
3648
os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "symbols")),
49+
os.path.abspath(
50+
os.path.join(CACHE_PATH, "symbols")
51+
), # User cache fallback for automatically downloaded temporary symbols
3752
]
3853
"""Default list of paths to load symbols from (volatility3/symbols and volatility3/framework/symbols)"""
3954

@@ -71,21 +86,9 @@
7186
"""Logging level for four levels of detail: -vvvvvv"""
7287

7388

74-
CACHE_PATH = os.path.join(
75-
os.environ.get("XDG_CACHE_HOME") or os.path.join(os.path.expanduser("~"), ".cache"),
76-
"volatility3",
77-
)
78-
"""Default path to store cached data"""
79-
8089
SQLITE_CACHE_PERIOD = "-3 days"
8190
"""SQLite time modifier for how long each item is valid in the cache for"""
8291

83-
if sys.platform == "win32":
84-
CACHE_PATH = os.path.realpath(
85-
os.path.join(os.environ.get("APPDATA", os.path.expanduser("~")), "volatility3")
86-
)
87-
os.makedirs(CACHE_PATH, exist_ok=True)
88-
8992
IDENTIFIERS_FILENAME = "identifier.cache"
9093
"""Default location to record information about available identifiers"""
9194

0 commit comments

Comments
 (0)