longhuynh5713 opened a new pull request, #67019: URL: https://github.com/apache/airflow/pull/67019
The current implementation of `download_mail_attachments` in `ImapHook` silently overwrites files if they already exist in the target directory. This can lead to data loss when multiple emails have attachments with the same filename. This PR adds a configurable `overwrite` parameter (defaulting to `True` for backward compatibility) to `download_mail_attachments`. When set to `False`, the hook will automatically rename files by appending a numeric suffix (e.g., `report (1).csv`) if a collision is detected. Summary: - Added `overwrite` parameter to `download_mail_attachments`. - Implemented `_resolve_non_conflicting_path` helper to handle filename collisions. - Added comprehensive unit tests for both overwrite and collision-avoidance scenarios. - Updated the IMAP provider changelog. closes: #65870 --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes — gemini-3-flash-preview Generated-by: gemini-3-flash-preview 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]
