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 email_download_attachment( 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)