From 88694264debfb8ba4d9315317761e4306b26f528 Mon Sep 17 00:00:00 2001 From: Julien Cabillot Date: Fri, 20 Mar 2026 16:27:49 -0400 Subject: [PATCH] feat: add folders selection --- src/indexer.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/src/indexer.py b/src/indexer.py index 4301fb3..1375a03 100644 --- a/src/indexer.py +++ b/src/indexer.py @@ -23,6 +23,7 @@ load_dotenv() # Configuration MAILDIR_PATH = os.environ.get("MAILDIR_PATH", "") +MAILDIR_FOLDERS = os.environ.get("MAILDIR_FOLDERS", "") QDRANT_URL = os.environ.get("QDRANT_URL", "") COLLECTION_NAME = os.environ.get("COLLECTION_NAME", "") @@ -292,10 +293,25 @@ def main(): ) with ThreadPoolExecutor(max_workers=1) as executor: - # Iterate and parse over all maildir directories found in MAILDIR_PATH - for root, dirs, files in os.walk(MAILDIR_PATH): + # Determine which directories to process + maildir_roots = [] + if MAILDIR_FOLDERS: + folders = [f.strip() for f in MAILDIR_FOLDERS.split(",") if f.strip()] + for folder in folders: + folder_path = os.path.join(MAILDIR_PATH, folder) + if os.path.isdir(folder_path): + maildir_roots.append(folder_path) + else: + print(f"Warning: Specified folder not found: {folder_path}") + else: + for root_dir, dirs, _ in os.walk(MAILDIR_PATH): + if all(subdir in dirs for subdir in ['cur', 'new', 'tmp']): + maildir_roots.append(root_dir) + + # Iterate and parse over selected maildir directories + for root in maildir_roots: # A valid Maildir has 'cur', 'new', and 'tmp' subdirectories - if not all(subdir in dirs for subdir in ['cur', 'new', 'tmp']): + if not all(os.path.isdir(os.path.join(root, subdir)) for subdir in ['cur', 'new', 'tmp']): continue print(f"Processing Maildir found at: {root}")