uranusjr commented on a change in pull request #16792:
URL: https://github.com/apache/airflow/pull/16792#discussion_r663567017



##########
File path: airflow/providers/sftp/operators/sftp.py
##########
@@ -134,29 +176,68 @@ def execute(self, context: Any) -> str:
 
             with self.ssh_hook.get_conn() as ssh_client:
                 sftp_client = ssh_client.open_sftp()
-                if self.operation.lower() == SFTPOperation.GET:
-                    local_folder = os.path.dirname(self.local_filepath)
-                    if self.create_intermediate_dirs:
-                        Path(local_folder).mkdir(parents=True, exist_ok=True)
-                    file_msg = f"from {self.remote_filepath} to 
{self.local_filepath}"
-                    self.log.info("Starting to transfer %s", file_msg)
-                    sftp_client.get(self.remote_filepath, self.local_filepath)
+                if self.local_filepath and self.remote_filepath:
+                    if isinstance(self.local_filepath, list) and 
isinstance(self.remote_filepath, str):
+                        for file_path in self.local_filepath:
+                            local_folder = os.path.dirname(file_path)
+                            remote_folder = 
os.path.dirname(self.remote_filepath)
+                            local_file = ntpath.basename(file_path)

Review comment:
       But why not `os.path.basename`? `ntpath` splits on backslashes (as it 
should) and that would cause issues on Linux (where ``\`` is a valid character 
in file name).




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