Skip to content

Commit

Permalink
enable user plugin cache location
Browse files Browse the repository at this point in the history
  • Loading branch information
jmartin-tech committed Jul 23, 2024
1 parent 7ad6090 commit 73eb8f0
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion garak/_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ def default(self, obj):

class PluginCache:
_plugin_cache_file = _config.transient.basedir / "resources" / "plugin_cache.json"
_user_plugin_cache_file = _plugin_cache_file
_user_plugin_cache_file = (
_config.transient.cache_dir / "resources" / "plugin_cache.json"
)
_plugin_cache_dict = None

def __init__(self) -> None:
Expand All @@ -55,6 +57,9 @@ def _load_plugin_cache(self):
if not os.path.exists(self._plugin_cache_file):
self._build_plugin_cache()
if not os.path.exists(self._user_plugin_cache_file):
self._user_plugin_cache_file.parent.mkdir(
mode=0o740, parents=True, exist_ok=True
)
shutil.copy2(self._plugin_cache_file, self._user_plugin_cache_file)
with open(self._user_plugin_cache_file, "r", encoding="utf-8") as cache_file:
local_cache = json.load(cache_file)
Expand Down

0 comments on commit 73eb8f0

Please sign in to comment.