mirror of
https://github.com/mail-in-a-box/mailinabox.git
synced 2026-01-23 09:22:52 +01:00
Merge 64fdeec0fe into 3b53bf5ae4
This commit is contained in:
commit
8d22fa9ebf
@ -505,12 +505,10 @@ def list_target_files(config):
|
||||
from botocore.exceptions import ClientError
|
||||
|
||||
# separate bucket from path in target
|
||||
bucket = target.path[1:].split('/')[0]
|
||||
path = '/'.join(target.path[1:].split('/')[1:]) + '/'
|
||||
|
||||
# If no prefix is specified, set the path to '', otherwise boto won't list the files
|
||||
if path == '/':
|
||||
path = ''
|
||||
bucket_path = target.path.lstrip('/')
|
||||
bucket, _, path = bucket_path.partition('/')
|
||||
if path and not path.endswith('/'):
|
||||
path += '/'
|
||||
|
||||
if bucket == "":
|
||||
msg = "Enter an S3 bucket name."
|
||||
@ -525,7 +523,8 @@ def list_target_files(config):
|
||||
endpoint_url=f'https://{target.hostname}', \
|
||||
aws_access_key_id=config['target_user'], \
|
||||
aws_secret_access_key=config['target_pass'])
|
||||
bucket_objects = s3.list_objects_v2(Bucket=bucket, Prefix=path)['Contents']
|
||||
response = s3.list_objects_v2(Bucket=bucket, Prefix=path)
|
||||
bucket_objects = response.get('Contents', [])
|
||||
backup_list = [(key['Key'][len(path):], key['Size']) for key in bucket_objects]
|
||||
except ClientError as e:
|
||||
raise ValueError(e)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user