Skip to content
Python

Fix attachment de-dup stripping real digits from the filename

Osamaali313330e12131e49
diff --git a/coworker/connectors/email_tools.py b/coworker/connectors/email_tools.py
index 3682b1da..7be4e1f9 100644
--- a/coworker/connectors/email_tools.py
+++ b/coworker/connectors/email_tools.py
@@ -555,7 +555,7 @@ def make_email_tools(
while target.exists():
target = (
scratch.path
- / f"{target.stem.rstrip('-0123456789') or 'attachment'}-{counter}{target.suffix}"
+ / f"{re.sub(r'-[0-9]+$', '', target.stem) or 'attachment'}-{counter}{target.suffix}"
)
counter += 1
target.write_bytes(payload)