From 4fd5726ec525ecf3a7fd88dfd9916ec33b6239fd Mon Sep 17 00:00:00 2001 From: pythongosssss <125205205+pythongosssss@users.noreply.github.com> Date: Tue, 22 Aug 2023 13:47:25 +0100 Subject: [PATCH] Fix crash --- py/lora_info.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/py/lora_info.py b/py/lora_info.py index 8dcc2f7..898b384 100644 --- a/py/lora_info.py +++ b/py/lora_info.py @@ -5,6 +5,7 @@ from server import PromptServer import folder_paths import os + def get_metadata(filepath): with open(filepath, "rb") as file: # https://github.com/huggingface/safetensors#format @@ -33,8 +34,10 @@ async def load_metadata(request): type, name) if not file_path: return web.Response(status=404) - + meta = get_metadata(file_path) + if meta is None: + meta = {} file_no_ext = os.path.splitext(file_path)[0] @@ -52,6 +55,5 @@ async def load_metadata(request): meta["pysssss.sha256"] = hashlib.sha256(f.read()).hexdigest() with open(hash_file, "wt") as f: f.write(meta["pysssss.sha256"]) - return web.json_response(meta)