pateash commented on code in PR #40022:
URL: https://github.com/apache/airflow/pull/40022#discussion_r1631152676
##########
airflow/providers/sftp/hooks/sftp.py:
##########
@@ -558,13 +558,17 @@ async def get_mod_time(self, path: str) -> str:
:param path: full path to the remote file
"""
- ssh_conn = await self._get_conn()
- sftp_client = await ssh_conn.start_sftp_client()
+ ssh_conn = None
try:
+ ssh_conn = await self._get_conn()
+ sftp_client = await ssh_conn.start_sftp_client()
ftp_mdtm = await sftp_client.stat(path)
modified_time = ftp_mdtm.mtime
mod_time =
datetime.datetime.fromtimestamp(modified_time).strftime("%Y%m%d%H%M%S") #
type: ignore[arg-type]
self.log.info("Found File %s last modified: %s", str(path),
str(mod_time))
return mod_time
except asyncssh.SFTPNoSuchFile:
raise AirflowException("No files matching")
+ finally:
Review Comment:
I have tried it, but getting mypy violations.
--
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]