From 1c8b35399c474f34911a2d8d577824bfc40852e0 Mon Sep 17 00:00:00 2001 From: curo1305 Date: Sat, 18 Apr 2026 22:26:24 +0200 Subject: [PATCH] fix: capitalize watch-folder names to PascalCase-with-dashes on ingest Folder names like "invoices" and "vendor-invoices" are now converted to "Invoices" and "Vendor-Invoices" when the watcher auto-creates categories, matching the naming convention enforced on user-created categories. Co-Authored-By: Claude Sonnet 4.6 --- features/doc-service/app/services/file_watcher.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/features/doc-service/app/services/file_watcher.py b/features/doc-service/app/services/file_watcher.py index e9de9d7..adb06f7 100644 --- a/features/doc-service/app/services/file_watcher.py +++ b/features/doc-service/app/services/file_watcher.py @@ -11,7 +11,8 @@ Key design decisions: - Watch documents use user_id="watch" as a sentinel so they are visible to all authenticated users in the document list. - Subfolder names map to categories: a file at invoices/bill.pdf is assigned - to a "invoices" category (auto-created if needed). + to an "Invoices" category (auto-created if needed; folder name is converted + to PascalCase-with-dashes: "vendor-invoices" → "Vendor-Invoices"). - Suggestions: if ai_folder_suggestion or ai_rename_suggestion are enabled, the relevant fields are set on the document after AI processing so users can confirm/reject from the UI. @@ -21,6 +22,7 @@ Key design decisions: import asyncio import json import logging +import re import uuid from pathlib import Path @@ -66,7 +68,10 @@ async def ingest_file(path_str: str, watch_root: Path, config: dict) -> None: # Determine category from the first subfolder component try: rel = path.relative_to(watch_root) - folder_name = rel.parts[0] if len(rel.parts) > 1 else None + folder_name = ( + "-".join(p.capitalize() for p in re.split(r"[-_\s]+", rel.parts[0]) if p) + if len(rel.parts) > 1 else None + ) except ValueError: folder_name = None