BBQing commented on code in PR #51167:
URL: https://github.com/apache/airflow/pull/51167#discussion_r2114767534
##########
providers/sftp/src/airflow/providers/sftp/sensors/sftp.py:
##########
@@ -89,22 +89,23 @@ def poke(self, context: Context) -> PokeReturnValue | bool:
if self.file_pattern:
files_from_pattern = self.hook.get_files_by_pattern(self.path,
self.file_pattern)
if files_from_pattern:
- actual_files_to_check = [
+ actual_files_present = [
os.path.join(self.path, file_from_pattern) for
file_from_pattern in files_from_pattern
]
else:
return False
else:
try:
- self.hook.isfile(self.path)
- actual_files_to_check = [self.path]
+ # File that did not exist was still being added to the list,
which was causing the Sensor
+ # to return True, even if the file was not present
+ actual_files_present = [self.path] if
self.hook.isfile(self.path) else []
except OSError as e:
if e.errno != SFTP_NO_SUCH_FILE:
raise AirflowException from e
- actual_files_to_check = []
+ actual_files_present = []
if self.newer_than:
- for actual_file_to_check in actual_files_to_check:
+ for actual_file_to_check in actual_files_present:
Review Comment:
I don't want to point it out :) but also here should be the name different
for the item in the iteration
--
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]