diff --git a/scripts/tag_autocomplete_helper.py b/scripts/tag_autocomplete_helper.py index a11d645..486056f 100644 --- a/scripts/tag_autocomplete_helper.py +++ b/scripts/tag_autocomplete_helper.py @@ -69,12 +69,13 @@ def get_wildcards(): def get_ext_wildcards(): """Returns a list of all extension wildcards. Works on nested folders.""" wildcard_files = [] - + excluded_folder_names = [s.strip() for s in getattr(shared.opts, "tac_wildcardExclusionList", "").split(",")] for path in WILDCARD_EXT_PATHS: wildcard_files.append(path.as_posix()) resolved = [(w, w.relative_to(path).as_posix()) for w in path.rglob("*.txt") if w.name != "put wildcards here.txt" + and not any(excluded in w.parts for excluded in excluded_folder_names) and w.is_file()] wildcard_files.extend(sort_models(resolved, name_has_subpath=True)) wildcard_files.append("-----") @@ -384,19 +385,21 @@ def refresh_embeddings(force: bool, *args, **kwargs): def refresh_temp_files(*args, **kwargs): global WILDCARD_EXT_PATHS - WILDCARD_EXT_PATHS = find_ext_wildcard_paths() - write_temp_files() + skip_wildcard_refresh = getattr(shared.opts, "tac_skipWildcardRefresh", False) + if skip_wildcard_refresh: + WILDCARD_EXT_PATHS = find_ext_wildcard_paths() + write_temp_files(skip_wildcard_refresh) refresh_embeddings(force=True) -def write_temp_files(): +def write_temp_files(skip_wildcard_refresh = False): # Write wildcards to wc.txt if found - if WILDCARD_PATH.exists(): + if WILDCARD_PATH.exists() and not skip_wildcard_refresh: wildcards = [WILDCARD_PATH.relative_to(FILE_DIR).as_posix()] + get_wildcards() if wildcards: write_to_temp_file('wc.txt', wildcards) # Write extension wildcards to wce.txt if found - if WILDCARD_EXT_PATHS is not None: + if WILDCARD_EXT_PATHS is not None and not skip_wildcard_refresh: wildcards_ext = get_ext_wildcards() if wildcards_ext: write_to_temp_file('wce.txt', wildcards_ext) @@ -466,6 +469,8 @@ def on_ui_settings(): "tac_delayTime": shared.OptionInfo(100, "Time in ms to wait before triggering completion again").needs_restart(), "tac_useWildcards": shared.OptionInfo(True, "Search for wildcards"), "tac_sortWildcardResults": shared.OptionInfo(True, "Sort wildcard file contents alphabetically").info("If your wildcard files have a specific custom order, disable this to keep it"), + "tac_wildcardExclusionList": shared.OptionInfo("", "Wildcard folder exclusion list").info("Add folder names that shouldn't be searched for wildcards, separated by comma.").needs_restart(), + "tac_skipWildcardRefresh": shared.OptionInfo(False, "Don't re-scan for wildcard files when pressing the extra networks refresh button").info("Useful to prevent hanging if you use a very large wildcard collection."), "tac_useEmbeddings": shared.OptionInfo(True, "Search for embeddings"), "tac_includeEmbeddingsInNormalResults": shared.OptionInfo(False, "Include embeddings in normal tag results").info("The 'JumpTo...' keybinds (End & Home key by default) will select the first non-embedding result of their direction on the first press for quick navigation in longer lists."), "tac_useHypernetworks": shared.OptionInfo(True, "Search for hypernetworks"),