aboutsummaryrefslogtreecommitdiffstats
path: root/modules/hashes.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-07-14 07:12:48 +0000
committerAUTOMATIC1111 <16777216c@gmail.com>2023-07-14 07:12:48 +0000
commit92a3236161099aca735c3f59f30859750d9e7452 (patch)
treeffc981e3fdd856dbc389af2e56f0d97d38ecaec1 /modules/hashes.py
parent9a3f35b028a8026291679c35e1df5b2aea327a1d (diff)
parent9893d09b4378d14c2a3ef370a5e02b906993ea86 (diff)
downloadstable-diffusion-webui-gfx803-92a3236161099aca735c3f59f30859750d9e7452.tar.gz
stable-diffusion-webui-gfx803-92a3236161099aca735c3f59f30859750d9e7452.tar.bz2
stable-diffusion-webui-gfx803-92a3236161099aca735c3f59f30859750d9e7452.zip
Merge branch 'dev' into sdxl
Diffstat (limited to 'modules/hashes.py')
-rw-r--r--modules/hashes.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/modules/hashes.py b/modules/hashes.py
index 8b7ea0ac..ec1187fe 100644
--- a/modules/hashes.py
+++ b/modules/hashes.py
@@ -5,7 +5,7 @@ import os.path
import filelock
from modules import shared
-from modules.paths import data_path
+from modules.paths import data_path, script_path
cache_filename = os.path.join(data_path, "cache.json")
@@ -26,8 +26,13 @@ def cache(subsection):
if not os.path.isfile(cache_filename):
cache_data = {}
else:
- with open(cache_filename, "r", encoding="utf8") as file:
- cache_data = json.load(file)
+ 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