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

   ## Motivation
   
   When using `imap_hook.download_mail_attachments`, attachments with identical 
filenames are silently overwritten, causing data loss. This PR adds a 
configurable `overwrite_file` parameter to control how filename collisions are 
handled.
   
   Closes: #65870
   
   ## Changes
   
   - Added `overwrite_file: bool = True` keyword-only parameter to 
`download_mail_attachments`
   - When `overwrite_file=True` (default): files are overwritten as before 
(preserving backward compatibility)
   - When `overwrite_file=False`: duplicate filenames get `_1`, `_2`, etc. 
suffixes inserted before the last extension (e.g., `test.tar.gz` → 
`test.tar_1.gz`)
   - Updated internal `_create_files` and `_create_file` methods to accept and 
use the new parameter
   - Added 3 new unit tests covering:
     - `overwrite_file=False` verifying `xb` mode is used
     - `overwrite_file=True` verifying files are overwritten and no copies exist
     - `overwrite_file=False` verifying incremental suffix creation with 
various filename patterns
   
   ## Reference
   
   This implements the same approach proposed in PR #62321 (closed without 
merge).


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