From f0313066da2b898d1bac940f027d54e90cd1737a Mon Sep 17 00:00:00 2001 From: Ace Date: Tue, 25 Jun 2024 19:38:28 +0200 Subject: [PATCH] create cache directory if not found --- inkycal/utils/json_cache.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/inkycal/utils/json_cache.py b/inkycal/utils/json_cache.py index 76e8e19..dda173a 100644 --- a/inkycal/utils/json_cache.py +++ b/inkycal/utils/json_cache.py @@ -12,6 +12,10 @@ settings = Settings() class JSONCache: def __init__(self, name: str, create_if_not_exists: bool = True): self.path = os.path.join(settings.CACHE_PATH,f"{name}.json") + + if not os.path.exists(settings.CACHE_PATH): + os.makedirs(settings.CACHE_PATH) + if create_if_not_exists and not os.path.exists(self.path): with open(self.path, "w", encoding="utf-8") as file: json.dump({}, file)