diff options
author | Vilém Duha <vilda.novak@gmail.com> | 2020-04-03 03:31:19 +0300 |
---|---|---|
committer | Vilém Duha <vilda.novak@gmail.com> | 2020-04-03 03:32:48 +0300 |
commit | 6f53879aaa9d0ca9691761609109be11b0daaf92 (patch) | |
tree | 9d6de72089076ec5dd67ee7b80e6741141046cd6 /blenderkit/paths.py | |
parent | 876acc1cd2de3dd5a46acef67c6f158232230011 (diff) |
BlenderKit: fix a problem with global dict
wasn't found if the path changed and this broke registration of addon.
Diffstat (limited to 'blenderkit/paths.py')
-rw-r--r-- | blenderkit/paths.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/blenderkit/paths.py b/blenderkit/paths.py index 112e2465..daf56b96 100644 --- a/blenderkit/paths.py +++ b/blenderkit/paths.py @@ -84,12 +84,21 @@ def get_temp_dir(subdir=None): tempdir = os.path.join(user_preferences.global_dir, 'temp') if tempdir.startswith('//'): tempdir = bpy.path.abspath(tempdir) - if not os.path.exists(tempdir): - os.makedirs(tempdir) - if subdir is not None: - tempdir = os.path.join(tempdir, subdir) + try: if not os.path.exists(tempdir): os.makedirs(tempdir) + if subdir is not None: + tempdir = os.path.join(tempdir, subdir) + if not os.path.exists(tempdir): + os.makedirs(tempdir) + except: + print('Cache directory not found. Resetting Cache folder path.') + p = default_global_dict() + if p == user_preferences.global_dir: + print('Global dir was already default, plese set a global directory in addon preferences to a dir where you have write permissions.') + return None + user_preferences.global_dir = p + tempdir = get_temp_dir(subdir = subdir) return tempdir |