From 3903daa39874d784426923e3824a9d38c8399999 Mon Sep 17 00:00:00 2001
From: Vangelis Kostalas <kostalas.v@gmail.com>
Date: Thu, 11 Jul 2019 09:53:31 +0300
Subject: [PATCH] Create the icon cache directory when the extension first
 runs.

---
 main.py | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/main.py b/main.py
index 0a09602..311ed63 100644
--- a/main.py
+++ b/main.py
@@ -46,6 +46,7 @@ class UnicodeChar:
 class UnicodeCharExtension(Extension):
     def __init__(self):
         super(UnicodeCharExtension, self).__init__()
+        check_cache_dir()
         self._load_character_table()
         self.subscribe(KeywordQueryEvent, KeywordQueryEventListener())
 
@@ -104,5 +105,13 @@ def create_character_icon(char, font="sans-serif"):
     return os.path.join(FILE_PATH, "images/cache/icon_%s.svg" % char.code)
 
 
+def check_cache_dir(path="images/cache"):
+    """ Check if the cache directory exists and if not create it.
+    """
+    path = os.path.join(FILE_PATH, path)
+    if not os.path.isdir(path):
+        os.mkdir(path)
+
+
 if __name__ == "__main__":
     UnicodeCharExtension().run()