diff options
author | w-e-w <40751091+w-e-w@users.noreply.github.com> | 2023-07-13 20:48:14 +0000 |
---|---|---|
committer | w-e-w <40751091+w-e-w@users.noreply.github.com> | 2023-07-13 20:48:14 +0000 |
commit | a3db187e4f1ef59a571b1023309923f5e5e6dda3 (patch) | |
tree | 039ce756fe3dd60141950c82bf066166017f9875 /modules/hashes.py | |
parent | 066d5edf174c06aeb30d705a8a164d3fdfd86fef (diff) | |
download | stable-diffusion-webui-gfx803-a3db187e4f1ef59a571b1023309923f5e5e6dda3.tar.gz stable-diffusion-webui-gfx803-a3db187e4f1ef59a571b1023309923f5e5e6dda3.tar.bz2 stable-diffusion-webui-gfx803-a3db187e4f1ef59a571b1023309923f5e5e6dda3.zip |
handles model hash cache.json error
Diffstat (limited to 'modules/hashes.py')
-rw-r--r-- | modules/hashes.py | 11 |
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
|