You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2021/07/04 16:50:40 UTC

[GitHub] [airflow] AngryHelper commented on a change in pull request #16792: [AIRFLOW-5703] SFTP Provider list of files and directories

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



##########
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:
       I needed to take the name of file from full path, this function was just right for this task :)




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