Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Take into account additional headers in cp and sync commands. #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions S3/S3.py
Expand Up @@ -416,10 +416,17 @@ def object_copy(self, src_uri, dst_uri, extra_headers = None):
headers["x-amz-acl"] = "public-read"
if self.config.reduced_redundancy:
headers["x-amz-storage-class"] = "REDUCED_REDUNDANCY"
# if extra_headers:
# headers.update(extra_headers)
if extra_headers:
headers.update(extra_headers)
request = self.create_request("OBJECT_PUT", uri = dst_uri, headers = headers)
response = self.send_request(request)
try:
response = self.send_request(request)
except Exception, e:
if e.status == 412:
# PreconditionFailed response - this is ok, just skip
return {"status": e.status}
else:
raise e
return response

def object_move(self, src_uri, dst_uri, extra_headers = None):
Expand Down
6 changes: 6 additions & 0 deletions s3cmd
Expand Up @@ -535,6 +535,9 @@ def subcmd_cp_mv(args, process_fce, action_str, message):

extra_headers = copy(cfg.extra_headers)
response = process_fce(src_uri, dst_uri, extra_headers)
if response['status'] == 412:
info(u"Skipping file %s" % src_uri)
continue
output(message % { "src" : src_uri, "dst" : dst_uri })
if Config().acl_public:
info(u"Public URL is: %s" % dst_uri.public_url())
Expand Down Expand Up @@ -645,6 +648,9 @@ def cmd_sync_remote2remote(args):
extra_headers = copy(cfg.extra_headers)
try:
response = s3.object_copy(src_uri, dst_uri, extra_headers)
if response['status'] == 412:
output("Skipping file %s" % src_uri)
continue
output("File %(src)s copied to %(dst)s" % { "src" : src_uri, "dst" : dst_uri })
except S3Error, e:
error("File %(src)s could not be copied: %(e)s" % { "src" : src_uri, "e" : e })
Expand Down