vincbeck commented on code in PR #39950:
URL: https://github.com/apache/airflow/pull/39950#discussion_r1621288054


##########
airflow/providers/amazon/aws/sensors/s3.py:
##########
@@ -78,6 +78,11 @@ def check_fn(files: List) -> bool:
                  CA cert bundle than the one used by botocore.
     :param deferrable: Run operator in the deferrable mode
     :param use_regex: whether to use regex to check bucket
+    :param metadata_keys: List of head_object attributes to to gather and send 
to check_fn.

Review Comment:
   ```suggestion
       :param metadata_keys: List of head_object attributes to gather and send 
to ``check_fn``.
   ```



##########
airflow/providers/amazon/aws/sensors/s3.py:
##########
@@ -123,8 +129,25 @@ def _check_key(self, key):
             if not key_matches:
                 return False
 
-            # Reduce the set of metadata to size only
-            files = [{"Size": f["Size"]} for f in key_matches]
+            # Reduce the set of metadata to requested attributes
+            files = []
+            for f in key_matches:
+                metadata = {}
+                if "*" in self.metadata_keys:
+                    metadata = self.hook.head_object(f["Key"], bucket_name)
+                else:
+                    for key in self.metadata_keys:
+                        # backwards compatibility with original implementation
+                        if key == "Size":
+                            metadata[key] = f.get("ContentLength")

Review Comment:
   Why? As far as I can see, original implementation uses `Size` and not 
`ContentLength`



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