diff options
author | wangshuai09 <391746016@qq.com> | 2024-01-30 11:15:41 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-30 11:15:41 +0000 |
commit | 74ff85a1a1ee4cce432b1c7d33c1eda831f68d48 (patch) | |
tree | 99b70e0fef8422c8f603bf7faa1a393091cb2a8b /modules/cache.py | |
parent | ec124607f47371a6cfd61a795f86a7f1cbd44651 (diff) | |
parent | ce168ab5dbc8b54b7245f352a2eaa55a37019b91 (diff) | |
download | stable-diffusion-webui-gfx803-74ff85a1a1ee4cce432b1c7d33c1eda831f68d48.tar.gz stable-diffusion-webui-gfx803-74ff85a1a1ee4cce432b1c7d33c1eda831f68d48.tar.bz2 stable-diffusion-webui-gfx803-74ff85a1a1ee4cce432b1c7d33c1eda831f68d48.zip |
Merge branch 'dev' into npu_support
Diffstat (limited to 'modules/cache.py')
-rw-r--r-- | modules/cache.py | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/modules/cache.py b/modules/cache.py index 2d37e7b9..a9822a0e 100644 --- a/modules/cache.py +++ b/modules/cache.py @@ -62,16 +62,15 @@ def cache(subsection): if cache_data is None:
with cache_lock:
if cache_data is None:
- if not os.path.isfile(cache_filename):
+ try:
+ with open(cache_filename, "r", encoding="utf8") as file:
+ cache_data = json.load(file)
+ except FileNotFoundError:
+ cache_data = {}
+ except Exception:
+ os.replace(cache_filename, os.path.join(script_path, "tmp", "cache.json"))
+ print('[ERROR] issue occurred while trying to read cache.json, move current cache to tmp/cache.json and create new cache')
cache_data = {}
- else:
- try:
- with open(cache_filename, "r", encoding="utf8") as file:
- cache_data = json.load(file)
- except Exception:
- os.replace(cache_filename, os.path.join(script_path, "tmp", "cache.json"))
- print('[ERROR] issue occurred while trying to read cache.json, move current cache to tmp/cache.json and create new cache')
- cache_data = {}
s = cache_data.get(subsection, {})
cache_data[subsection] = s
|