jroachgolf84 commented on code in PR #55070:
URL: https://github.com/apache/airflow/pull/55070#discussion_r2359585799


##########
providers/amazon/src/airflow/providers/amazon/aws/sensors/s3.py:
##########
@@ -122,8 +122,20 @@ def _check_key(self, key, context: Context):
         """
         if self.wildcard_match:
             prefix = re.split(r"[\[*?]", key, 1)[0]
-            keys = self.hook.get_file_metadata(prefix, bucket_name)
-            key_matches = [k for k in keys if fnmatch.fnmatch(k["Key"], key)]
+
+            key_matches: list[str] = []
+
+            # Is check_fn is None, then we can return True without having to 
iterate through each value in
+            # yielded by iter_file_metadata. Otherwise, we'll check for a 
match, and add all matches to the
+            # key_matches list
+            for k in self.hook.iter_file_metadata(prefix, bucket_name):
+                if fnmatch.fnmatch(k["Key"], key):
+                    if self.check_fn is not None:
+                        key_matches.append(k)

Review Comment:
   Agreed - I'm inclined to change that functionality outside of things PR; 
it's used quite a bit elsewhere in the AWS Provider.



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

Reply via email to