From 979953cf45f00575983400d1d8ff9258936fe953 Mon Sep 17 00:00:00 2001 From: Justin Bollinger Date: Fri, 24 Apr 2026 23:37:58 -0400 Subject: [PATCH] feat(api): skip already-present wordlists in list_and_download_official_wordlists Before each download in both the 'all' and indexed-selection branches, check whether the destination file already exists and has nonzero size (accounting for .7z archives whose extracted name drops the suffix). Mirrors the same guard already in place for rule downloads. Co-Authored-By: Claude Sonnet 4.6 --- hate_crack/api.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hate_crack/api.py b/hate_crack/api.py index 62c8117..af4867b 100644 --- a/hate_crack/api.py +++ b/hate_crack/api.py @@ -1677,6 +1677,17 @@ def list_and_download_official_wordlists(): ) if sel.lower() == "q": return + dest_dir = get_hcat_wordlists_dir() + + def _already_downloaded_wordlist(file_name): + sanitized = sanitize_filename(file_name) + if sanitized.endswith(".7z"): + extracted_name = sanitized[:-3] + check_path = os.path.join(dest_dir, extracted_name) + else: + check_path = os.path.join(dest_dir, sanitized) + return os.path.isfile(check_path) and os.path.getsize(check_path) > 0 + if sel.lower() == "a": try: for entry in data: @@ -1684,6 +1695,9 @@ def list_and_download_official_wordlists(): if not file_name: print("No file_name found for an entry, skipping.") continue + if _already_downloaded_wordlist(file_name): + print(f"[i] Skipping {file_name} (already present)") + continue out_path = entry.get("file_name", file_name) download_official_wordlist(file_name, out_path) except KeyboardInterrupt: @@ -1723,6 +1737,9 @@ def list_and_download_official_wordlists(): if not file_name: print("No file_name found for selection, skipping.") continue + if _already_downloaded_wordlist(file_name): + print(f"[i] Skipping {file_name} (already present)") + continue out_path = entry.get("file_name", file_name) download_official_wordlist(file_name, out_path) except Exception as e: