mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
Sort results of hashes in _hash_dir to always get the same result, remove dependency on os.walk
This commit is contained in:
parent
3bb50926af
commit
cb99a5f0e4
@ -114,6 +114,7 @@ class ModelHash:
|
|||||||
|
|
||||||
# BLAKE3 to hash the hashes
|
# BLAKE3 to hash the hashes
|
||||||
composite_hasher = blake3()
|
composite_hasher = blake3()
|
||||||
|
component_hashes.sort()
|
||||||
for h in component_hashes:
|
for h in component_hashes:
|
||||||
composite_hasher.update(h.encode("utf-8"))
|
composite_hasher.update(h.encode("utf-8"))
|
||||||
return composite_hasher.hexdigest()
|
return composite_hasher.hexdigest()
|
||||||
@ -131,10 +132,12 @@ class ModelHash:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
files: list[Path] = []
|
files: list[Path] = []
|
||||||
for root, _dirs, _files in os.walk(model_path):
|
entries = [entry for entry in os.scandir(model_path.as_posix()) if not entry.name.startswith(".")]
|
||||||
for file in _files:
|
dirs = [entry for entry in entries if entry.is_dir()]
|
||||||
if file_filter(file):
|
file_paths = [entry.path for entry in entries if entry.is_file() and file_filter(entry.path)]
|
||||||
files.append(Path(root, file))
|
files.extend([Path(file) for file in file_paths])
|
||||||
|
for dir in dirs:
|
||||||
|
files.extend(ModelHash._get_file_paths(Path(dir.path), file_filter))
|
||||||
return files
|
return files
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
Loading…
Reference in New Issue
Block a user