Skip to content

Commit

Permalink
cache: use path to code, not hardcoded relative path
Browse files Browse the repository at this point in the history
closes #2350
  • Loading branch information
williballenthin committed Sep 11, 2024
1 parent 729a1a8 commit 4da8a20
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion capa/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,10 @@ def is_cache_newer_than_rule_code(cache_dir: Path) -> bool:
cache_timestamp = os.path.getmtime(latest_cache_file)

# these are the relevant rules code files that could conflict with using an outdated cache
latest_rule_code_file = max([Path("capa/rules/__init__.py"), Path("capa/rules/cache.py")], key=os.path.getmtime)
# delayed import due to circular dependencies
import capa.rules
import capa.rules.cache
latest_rule_code_file = max([Path(capa.rules.__file__), Path(capa.rules.cache.__file__)], key=os.path.getmtime)
rule_code_timestamp = os.path.getmtime(latest_rule_code_file)

if rule_code_timestamp > cache_timestamp:
Expand Down

0 comments on commit 4da8a20

Please sign in to comment.