feat: add folders selection
All checks were successful
perso/mcp-maildir/pipeline/head This commit looks good

This commit is contained in:
Julien Cabillot
2026-03-20 16:27:49 -04:00
parent d5415da5d9
commit 88694264de

View File

@@ -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}")