2
0
mirror of https://github.com/frappe/frappe_docker.git synced 2024-11-08 14:21:05 +00:00

Merge pull request #363 from sahil28297/fix_push_restore_backup

fix: do not consider directory objects
This commit is contained in:
Chinmay Pai 2020-10-06 21:34:42 +05:30 committed by GitHub
commit b0b838f80a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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('/')

View File

@ -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('/')