Skip to content

Commit

Permalink
Minor fix in do_get_s3_archive (#49)
Browse files Browse the repository at this point in the history
Fixed a potential bug in do_get_s3_archive and added Prefix when calling s3.list_objects_v2
  • Loading branch information
kyhau authored and bchew committed Mar 18, 2018
1 parent 3a001ce commit deee239
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dynamodump.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ def do_get_s3_archive(profile, region, bucket, table, archive):
try:
contents = s3.list_objects_v2(
Bucket=bucket,
Prefix=args.dumpPath
)
except botocore.exceptions.ClientError as e:
logging.exception("Issue listing contents of bucket " + bucket + "\n\n" + str(e))
Expand All @@ -187,7 +188,7 @@ def do_get_s3_archive(profile, region, bucket, table, archive):
# Therefore, just get item from bucket based on table name since that's what we name the files.
filename = None
for d in contents["Contents"]:
if d["Key"] == "dump/{}.{}".format(table, archive_type):
if d["Key"] == "{}/{}.{}".format(args.dumpPath, table, archive_type):
filename = d["Key"]

if not filename:
Expand Down

3 comments on commit deee239

@greenu
Copy link

@greenu greenu commented on deee239 Mar 28, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix has introduced another bug. When s3 dumped with explicit table name, dump name is dump.zip and it cannot be restored, because it looking for dump/tablename.zip and filename variable remains None.

@HarpreetSinghBhola
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, i am facing the same issue. Its unable to restore from S3 bucket.

@HarpreetSinghBhola
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it working by making changes at line 191:

if d["Key"] == "{}.{}".format(args.dumpPath, archive_type):

Please sign in to comment.