lohitkolluri opened a new pull request, #67899:
URL: https://github.com/apache/airflow/pull/67899

   When downloading mail attachments with the same filename, files were 
silently overwritten. Added a new ``create_unique_filenames`` parameter 
(default False) that appends a counter suffix (``_1``, ``_2``, etc.) to the 
base filename when a file already exists at the target path.
   
   The default is False to preserve backward compatibility - existing behavior 
of silently overwriting files remains unchanged.
   
   ## Root Cause
   When multiple emails had attachments with the same name, each call to 
`download_mail_attachments` would silently overwrite the previous file at the 
same path.
   
   ## Fix
   - Added `_get_unique_filepath` helper that finds the next available filename 
by incrementing a counter until no collision exists
   - Wired the `create_unique_filenames` flag through `_create_files` and 
`_create_file`
   - All 38 IMAP hook tests + 2 sensor tests pass
   
   ## Risks
   - Backward compatible: new parameter defaults to `False`
   - No change to existing behavior unless opt-in
   
   closes: #65870
   
   ---
   
   ##### Was generative AI tooling used to co-author this PR?
   
   - [X] Yes — Claude Code (DeepSeek V4 Flash)
   
   Generated-by: Claude Code (DeepSeek V4 Flash) following [the 
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to