This commit is contained in:
+19
-3
@@ -23,6 +23,7 @@ load_dotenv()
|
|||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
MAILDIR_PATH = os.environ.get("MAILDIR_PATH", "")
|
MAILDIR_PATH = os.environ.get("MAILDIR_PATH", "")
|
||||||
|
MAILDIR_FOLDERS = os.environ.get("MAILDIR_FOLDERS", "")
|
||||||
QDRANT_URL = os.environ.get("QDRANT_URL", "")
|
QDRANT_URL = os.environ.get("QDRANT_URL", "")
|
||||||
COLLECTION_NAME = os.environ.get("COLLECTION_NAME", "")
|
COLLECTION_NAME = os.environ.get("COLLECTION_NAME", "")
|
||||||
|
|
||||||
@@ -292,10 +293,25 @@ def main():
|
|||||||
)
|
)
|
||||||
|
|
||||||
with ThreadPoolExecutor(max_workers=1) as executor:
|
with ThreadPoolExecutor(max_workers=1) as executor:
|
||||||
# Iterate and parse over all maildir directories found in MAILDIR_PATH
|
# Determine which directories to process
|
||||||
for root, dirs, files in os.walk(MAILDIR_PATH):
|
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
|
# 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
|
continue
|
||||||
|
|
||||||
print(f"Processing Maildir found at: {root}")
|
print(f"Processing Maildir found at: {root}")
|
||||||
|
|||||||
Reference in New Issue
Block a user