Your lightweight open-source personal agent.
Python agent-frameworkai-agentai-agentschatbotchatopsdiscord-botllm-agentsllmslocal-llmmcpmodel-context-protocolmulti-agentopenai-compatibleopenclawpersonal-ai-assistantpythonself-hostedtelegram-bot-ai-assistantwebuiworkflow-automation
fix(email): preserve case-colliding attachment files
Xubin Rena389633b9c96
diff --git a/nanobot/channels/email/runtime.py b/nanobot/channels/email/runtime.pyindex d903c4d9d..660f40f26 100644--- a/nanobot/channels/email/runtime.py+++ b/nanobot/channels/email/runtime.py@@ -1196,6 +1196,7 @@ class EmailChannel(BaseChannel):return []saved: list[Path] = []+ saved_names: set[str] = set()media_dir = get_media_dir("email")for part in msg.walk():@@ -1225,13 +1226,14 @@ class EmailChannel(BaseChannel):filename = Path(f"{uid}_{sanitized}")dest = media_dir / filenameindex = 1- while dest in saved:+ while dest.name.casefold() in saved_names:dest = media_dir / f"{filename.stem}_{index}{filename.suffix}"index += 1try:dest.write_bytes(payload)saved.append(dest)+ saved_names.add(dest.name.casefold())logger.info("Attachment saved: {}", dest)except Exception as exc:logger.warning("Failed to save attachment {}: {}", dest, exc)diff --git a/nanobot/channels/email/tests/test_attachment_filenames.py b/nanobot/channels/email/tests/test_attachment_filenames.pyindex 81a80ea26..2eb2964cb 100644--- a/nanobot/channels/email/tests/test_attachment_filenames.py+++ b/nanobot/channels/email/tests/test_attachment_filenames.py@@ -13,6 +13,7 @@ from nanobot.channels.email.runtime import EmailChannel("report.txt", "report.txt"),("report:2026.txt", "report?2026.txt"),("report.txt", "report.txt", "report_1.txt"),+ ("report.txt", "REPORT.txt"),],)def test_extract_attachments_preserves_colliding_filenames(tmp_path, monkeypatch, filenames):