Hi Everybody,
I was very glad you had included the copy method in the latest releases,
but needed recursive copy for a project.
A patch to support recursive copy has been included in this mail.
I have only testet it with copy, but should work fine with move to.
Please write if you have any questions.
Regards,
Bo Stendal Sørensen / bss
--- /usr/bin/s3cmd 2009-02-23 10:55:43.000000000 +0100
+++ s3cmd_rcp 2009-02-23 10:50:22.000000000 +0100
@@ -521,14 +521,34 @@
if src_uri.type != "s3" or dst_uri.type != "s3":
raise ParameterError("Parameters are not URIs! Expected: %s" % commands['cp']['param'])
- if dst_uri.object() == "":
- dst_uri = S3Uri(dst_uri.uri() + src_uri.object())
-
extra_headers = copy(cfg.extra_headers)
- response = process_fce(src_uri, dst_uri, extra_headers)
- output(message % { "src" : src_uri, "dst" : dst_uri})
- if Config().acl_public:
- output(u"Public URL is: %s" % dst_uri.public_url())
+
+ if cfg.recursive:
+ src_list = fetch_remote_list(src_uri.uri(), recursive = True, require_attribs = True)
+ src_list, exclude_list = _filelist_filter_exclude_include(src_list)
+
+ if dst_uri.basename() == dst_uri.object():
+ dst_prefix = dst_uri.uri()[:-1]
+ else:
+ dst_prefix = dst_uri.uri()
+ if dst_uri.basename() == "":
+ dst_prefix += src_uri.object()
+ elif src_uri.basename() == "":
+ dst_prefix += "/"
+
+ for idx in src_list:
+ src_file_uri = S3Uri(src_list[idx]['object_uri_str'])
+ dst_file_uri = S3Uri(dst_prefix + src_list[idx]['object_key'][len(src_uri.object()):])
+ response = process_fce(src_file_uri, dst_file_uri, extra_headers)
+ output(message % { "src" : src_file_uri, "dst" : dst_file_uri})
+ else:
+ if dst_uri.object() == "":
+ dst_uri = S3Uri(dst_uri.uri() + src_uri.object())
+
+ response = process_fce(src_uri, dst_uri, extra_headers)
+ output(message % { "src" : src_uri, "dst" : dst_uri})
+ if Config().acl_public:
+ output(u"Public URL is: %s" % dst_uri.public_url())
def cmd_cp(args):
s3 = S3(Config())
------------------------------------------------------------------------------
Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
http://p.sf.net/sfu/XcvMzF8H
_______________________________________________
S3tools-general mailing list
S3tools-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/s3tools-general