From 3d1bcf88a27f90fe1d2d0211357cdbd46359f553 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Wed, 23 Aug 2023 07:26:57 +0000 Subject: [PATCH] fix hashing --- extensions-builtin/sd-webui-controlnet | 2 +- modules/hashes.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/extensions-builtin/sd-webui-controlnet b/extensions-builtin/sd-webui-controlnet index 943197e1b..fb000270b 160000 --- a/extensions-builtin/sd-webui-controlnet +++ b/extensions-builtin/sd-webui-controlnet @@ -1 +1 @@ -Subproject commit 943197e1be49d8ce1bf964e15dd19e386f5ad5b8 +Subproject commit fb000270beef677d2caedbaecb0ef923eaeef2eb diff --git a/modules/hashes.py b/modules/hashes.py index d4c35483a..ea8b91609 100644 --- a/modules/hashes.py +++ b/modules/hashes.py @@ -32,11 +32,11 @@ def calculate_sha256(filename): def sha256_from_cache(filename, title, use_addnet_hash=False): hashes = cache("hashes-addnet") if use_addnet_hash else cache("hashes") - ondisk_mtime = os.path.getmtime(filename) if title not in hashes: return None cached_sha256 = hashes[title].get("sha256", None) cached_mtime = hashes[title].get("mtime", 0) + ondisk_mtime = os.path.getmtime(filename) if os.path.isfile(filename) else 0 if ondisk_mtime > cached_mtime or cached_sha256 is None: return None return cached_sha256 @@ -49,6 +49,8 @@ def sha256(filename, title, use_addnet_hash=False): return sha256_value if shared.cmd_opts.no_hashing: return None + if not os.path.isfile(filename): + return None if use_addnet_hash: with progress.open(filename, 'rb', description=f'Calculating model hash: [cyan]{filename}', auto_refresh=True) as f: sha256_value = addnet_hash_safetensors(f)