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

   
   Closes: #65870
   
   ### What changed
   
   This adds an `overwrite_file` option to `ImapHook.download_mail_attachments`.
   
   By default, `overwrite_file=True` preserves the existing behavior and 
overwrites files with the same attachment filename.
   
   When `overwrite_file=False`, downloaded attachments are preserved by 
appending a numeric suffix when a filename collision is detected, for example:
   
   - `report.xlsx`
   - `report_1.xlsx`
   - `report_2.xlsx`
   
   The collision check handles both files already written during the current 
download call and files that already exist in the output directory.
   
   ### Tests
   
   Added IMAP hook unit tests covering:
   
   - default overwrite behavior
   - passing `overwrite_file=False` through `download_mail_attachments`
   - duplicate attachment names in one download call
   - collisions with files already present on disk
   
   Ran:
   
   ```text
   AIRFLOW_HOME=/tmp/airflow-65945-test .venv/bin/python -m pytest 
providers/imap/tests/unit/imap/hooks/test_imap.py -q --with-db-init
   .venv/bin/python -m ruff check 
providers/imap/src/airflow/providers/imap/hooks/imap.py 
providers/imap/tests/unit/imap/hooks/test_imap.py
   ```


-- 
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