diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2024-01-04 08:16:37 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-04 08:16:37 +0000 |
commit | 1e7a8ce5e403de4bef7e09f522a48ce5c1b1d845 (patch) | |
tree | d1d0df851e85ffc8c99cad308aad3137322fafff /modules/options.py | |
parent | 397251ba0cc1a1df2c558c28c416b64eef73a051 (diff) | |
parent | 50158a1fc9b4dd47a7bef70d34fbb0b30d5e8b47 (diff) | |
download | stable-diffusion-webui-gfx803-1e7a8ce5e403de4bef7e09f522a48ce5c1b1d845.tar.gz stable-diffusion-webui-gfx803-1e7a8ce5e403de4bef7e09f522a48ce5c1b1d845.tar.bz2 stable-diffusion-webui-gfx803-1e7a8ce5e403de4bef7e09f522a48ce5c1b1d845.zip |
Merge pull request #14525 from AUTOMATIC1111/handle-config.json-failed-to-load
handle config.json failed to load
Diffstat (limited to 'modules/options.py')
-rw-r--r-- | modules/options.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/modules/options.py b/modules/options.py index 09ff9403..503b40e9 100644 --- a/modules/options.py +++ b/modules/options.py @@ -1,3 +1,4 @@ +import os
import json
import sys
from dataclasses import dataclass
@@ -6,6 +7,7 @@ import gradio as gr from modules import errors
from modules.shared_cmd_options import cmd_opts
+from modules.paths_internal import script_path
class OptionInfo:
@@ -193,9 +195,13 @@ class Options: return type_x == type_y
def load(self, filename):
- with open(filename, "r", encoding="utf8") as file:
- self.data = json.load(file)
-
+ try:
+ with open(filename, "r", encoding="utf8") as file:
+ self.data = json.load(file)
+ except Exception:
+ errors.report(f'\nCould not load settings\nThe config file "{filename}" is likely corrupted\nIt has been moved to the "tmp/config.json"\nReverting config to default\n\n''', exc_info=True)
+ os.replace(filename, os.path.join(script_path, "tmp", "config.json"))
+ self.data = {}
# 1.6.0 VAE defaults
if self.data.get('sd_vae_as_default') is not None and self.data.get('sd_vae_overrides_per_model_preferences') is None:
self.data['sd_vae_overrides_per_model_preferences'] = not self.data.get('sd_vae_as_default')
|