fix: check if s3 object is a directory by checking the start of the object ContentType property

This commit is contained in:
Carlos Ríos 2022-02-23 19:26:35 -03:00
parent 66fca59f74
commit 46440d3894

View file

@ -75,7 +75,7 @@ def delete_old_backups(limit, bucket, site_name):
for obj in objects.get("CommonPrefixes"):
if obj.get("Prefix") == bucket_dir + "/":
for backup_obj in bucket.objects.filter(Prefix=obj.get("Prefix")):
if backup_obj.get()["ContentType"] == "application/x-directory":
if backup_obj.get()["ContentType"].startswith("application/x-directory"):
continue
try:
# backup_obj.key is bucket_dir/site/date_time/backupfile.extension