From 4c9ac34a2d240de5f09f4f167105e3def81a9372 Mon Sep 17 00:00:00 2001 From: tt4g <45120617+tt4g@users.noreply.github.com> Date: Mon, 26 Dec 2022 13:15:43 +0900 Subject: [PATCH] Allow changes to the cache base directory --- pyembedpg.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pyembedpg.py b/pyembedpg.py index 2f5c6bb..ff01201 100644 --- a/pyembedpg.py +++ b/pyembedpg.py @@ -48,10 +48,13 @@ def __init__(self, version=None): Initialize a new Postgres object :param version: version to use. If it is not set, use the latest version in .pyembedpg directory. If not present use the latest version remotely. Use 'local' to use the local postgres version installed on the machine + :param cache_base_dir: base directory path to save the cache files. If not present, the home directory is used. :return: """ - home_dir = expanduser("~") - self._cache_dir = os.path.join(home_dir, PyEmbedPg.CACHE_DIRECTORY) + if not cache_base_dir: + cache_base_dir = expanduser("~") + + self._cache_dir = os.path.join(cache_base_dir, PyEmbedPg.CACHE_DIRECTORY) # if version is not specified, check local last version otherwise get last remote version self.version = version