You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by "vaefremov95 (via GitHub)" <gi...@apache.org> on 2026/03/01 12:54:34 UTC

Re: [PR] add overwrite_file flag and unique attachment saving [airflow]

vaefremov95 commented on code in PR #62321:
URL: https://github.com/apache/airflow/pull/62321#discussion_r2868988350


##########
providers/imap/src/airflow/providers/imap/hooks/imap.py:
##########
@@ -310,11 +317,21 @@ def _correct_path(self, name: str, local_output_directory: str) -> str:
             else local_output_directory + "/" + name
         )
 
-    def _create_file(self, name: str, payload: Any, local_output_directory: str) -> None:
-        file_path = self._correct_path(name, local_output_directory)
-
-        with open(file_path, "wb") as file:
-            file.write(payload)
+    def _create_file(
+        self, name: str, payload: Any, local_output_directory: str, overwrite_file: bool
+    ) -> None:
+        filename, extensions = name.split(".", 1)
+        counter = 1
+        method = "wb" if overwrite_file else "xb"
+        while True:

Review Comment:
   @guan404ming 
   Hi!
   I would really appreciate it if you had a look at the new implementation. Is it sufficient or any additional changes are needed?
   Thanks!



-- 
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: commits-unsubscribe@airflow.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org