Update hashes.py
Browse files
hashes.py
CHANGED
|
@@ -21,7 +21,10 @@ def calculate_sha256(filename):
|
|
| 21 |
|
| 22 |
def sha256_from_cache(filename, title, use_addnet_hash=False):
|
| 23 |
hashes = cache("hashes-addnet") if use_addnet_hash else cache("hashes")
|
| 24 |
-
|
|
|
|
|
|
|
|
|
|
| 25 |
|
| 26 |
if title not in hashes:
|
| 27 |
return None
|
|
@@ -75,5 +78,4 @@ def addnet_hash_safetensors(b):
|
|
| 75 |
for chunk in iter(lambda: b.read(blksize), b""):
|
| 76 |
hash_sha256.update(chunk)
|
| 77 |
|
| 78 |
-
return hash_sha256.hexdigest()
|
| 79 |
-
|
|
|
|
| 21 |
|
| 22 |
def sha256_from_cache(filename, title, use_addnet_hash=False):
|
| 23 |
hashes = cache("hashes-addnet") if use_addnet_hash else cache("hashes")
|
| 24 |
+
try:
|
| 25 |
+
ondisk_mtime = os.path.getmtime(filename)
|
| 26 |
+
except FileNotFoundError:
|
| 27 |
+
return None
|
| 28 |
|
| 29 |
if title not in hashes:
|
| 30 |
return None
|
|
|
|
| 78 |
for chunk in iter(lambda: b.read(blksize), b""):
|
| 79 |
hash_sha256.update(chunk)
|
| 80 |
|
| 81 |
+
return hash_sha256.hexdigest()
|
|
|