fix: do not consider directory objects

This commit is contained in:
sahil28297
2020-10-06 20:47:56 +05:30
parent ec3ad0680a
commit 8e541e46e3
2 changed files with 4 additions and 0 deletions

View File

@@ -74,6 +74,8 @@ 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":
continue
try:
# backup_obj.key is bucket_dir/site/date_time/backupfile.extension
bucket_dir, site_slug, date_time, backupfile = backup_obj.key.split('/')