Skip to content

Commit

Permalink
Update actual_file_to_check with rendered path (#24451)
Browse files Browse the repository at this point in the history
  • Loading branch information
remem9527 authored Jun 17, 2022
1 parent ff6b971 commit ad297c9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions airflow/providers/sftp/sensors/sftp.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def __init__(
self.hook: Optional[SFTPHook] = None
self.sftp_conn_id = sftp_conn_id
self.newer_than: Optional[datetime] = newer_than
self.actual_file_to_check = self.path

def poke(self, context: 'Context') -> bool:
self.hook = SFTPHook(self.sftp_conn_id)
Expand All @@ -68,13 +67,15 @@ def poke(self, context: 'Context') -> bool:
if self.file_pattern:
file_from_pattern = self.hook.get_file_by_pattern(self.path, self.file_pattern)
if file_from_pattern:
self.actual_file_to_check = file_from_pattern
actual_file_to_check = file_from_pattern
else:
return False
else:
actual_file_to_check = self.path

try:
mod_time = self.hook.get_mod_time(self.actual_file_to_check)
self.log.info('Found File %s last modified: %s', str(self.actual_file_to_check), str(mod_time))
mod_time = self.hook.get_mod_time(actual_file_to_check)
self.log.info('Found File %s last modified: %s', str(actual_file_to_check), str(mod_time))
except OSError as e:
if e.errno != SFTP_NO_SUCH_FILE:
raise e
Expand Down

0 comments on commit ad297c9

Please sign in to comment.