Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update actual_file_to_check with rendered path #24451

Merged
merged 2 commits into from
Jun 17, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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