From 8e541e46e3fe6ed51b2248ced8533d41430476c4 Mon Sep 17 00:00:00 2001 From: sahil28297 Date: Tue, 6 Oct 2020 20:47:56 +0530 Subject: [PATCH] fix: do not consider directory objects --- build/common/commands/push_backup.py | 2 ++ build/common/commands/restore_backup.py | 2 ++ 2 files changed, 4 insertions(+) diff --git a/build/common/commands/push_backup.py b/build/common/commands/push_backup.py index ce3fa3d8..246eb362 100644 --- a/build/common/commands/push_backup.py +++ b/build/common/commands/push_backup.py @@ -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('/') diff --git a/build/common/commands/restore_backup.py b/build/common/commands/restore_backup.py index 6368d03a..9989d18d 100644 --- a/build/common/commands/restore_backup.py +++ b/build/common/commands/restore_backup.py @@ -116,6 +116,8 @@ def pull_backup_from_s3(): download_backups = [] for obj in bucket.objects.filter(Prefix=bucket_dir): + if obj.get()["ContentType"] == "application/x-directory": + continue backup_file = obj.key.replace(os.path.join(bucket_dir, ''), '') backup_files.append(backup_file) site_name, timestamp, backup_type = backup_file.split('/')