Browse code

Fixing bug 3091912 - KeyError when copying multiple keys

When you use 's3cmd cp' to copy multiple keys (without using the recursive flag) you get a Key Error.
s3cmd cp s3://source-bucket/prefix* s3://target-bucket

Logged here: http://sourceforge.net/tracker/?func=detail&aid=3091912&group_id=178907&atid=887015
and here: https://bugs.launchpad.net/ubuntu/+source/s3cmd/+bug/523586

Christopher Porter authored on 2012/01/07 14:42:43
Showing 1 changed files
... ...
@@ -1,4 +1,4 @@
1
-#!/usr/bin/env python
1
+#!/usr/bin/python
2 2
 
3 3
 ## Amazon S3 manager
4 4
 ## Author: Michal Ludvig <michal@logix.cz>
... ...
@@ -509,11 +509,11 @@ def subcmd_cp_mv(args, process_fce, action_str, message):
509 509
         for key in remote_list:
510 510
             remote_list[key]['dest_name'] = destination_base + key
511 511
     else:
512
-        key = remote_list.keys()[0]
513
-        if destination_base.endswith("/"):
514
-            remote_list[key]['dest_name'] = destination_base + key
515
-        else:
516
-            remote_list[key]['dest_name'] = destination_base
512
+        for key in remote_list:
513
+            if destination_base.endswith("/"):
514
+                remote_list[key]['dest_name'] = destination_base + key
515
+            else:
516
+                remote_list[key]['dest_name'] = destination_base
517 517
 
518 518
     if cfg.dry_run:
519 519
         for key in exclude_list: