From b19ecf410b6cc7e69311385eb7750dbe1c9bf4e7 Mon Sep 17 00:00:00 2001 From: Manuel Schmid Date: Mon, 1 Jul 2024 17:44:52 +0200 Subject: [PATCH] feat: add attribute --rebuild-hash-cache, add handling --- args_manager.py | 5 ++++- modules/config.py | 14 +++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/args_manager.py b/args_manager.py index 5a2b37c9..27fe14a5 100644 --- a/args_manager.py +++ b/args_manager.py @@ -32,7 +32,10 @@ args_parser.parser.add_argument("--enable-describe-uov-image", action='store_tru help="Disables automatic description of uov images when prompt is empty", default=False) args_parser.parser.add_argument("--always-download-new-model", action='store_true', - help="Always download newer models ", default=False) + help="Always download newer models", default=False) + +args_parser.parser.add_argument("--rebuild-hash-cache", action='store_true', + help="Generates missing model and LoRA hashes.", default=False) args_parser.parser.set_defaults( disable_cuda_malloc=True, diff --git a/modules/config.py b/modules/config.py index 1fd4412b..2f958ff6 100644 --- a/modules/config.py +++ b/modules/config.py @@ -757,5 +757,17 @@ def downloading_safety_checker_model(): update_files() load_cache_from_file() -# write cache to file again for cleanup of invalid cache entries + +if args_manager.args.rebuild_hash_cache: + from modules.hash_cache import sha256_from_cache + from modules.util import get_file_from_folder_list + + for filename in model_filenames: + filepath = get_file_from_folder_list(filename, paths_checkpoints) + sha256_from_cache(filepath) + for filename in lora_filenames: + filepath = get_file_from_folder_list(filename, paths_loras) + sha256_from_cache(filepath) + +# write cache to file again for sorting and cleanup of invalid cache entries save_cache_to_file()