Permalink
Browse files

* S3/S3.py: Some errors during file upload were incorrectly

  interpreted as MD5 mismatch. (bug #2384990)



git-svn-id: https://s3tools.svn.sourceforge.net/svnroot/s3tools/s3cmd/trunk@333 830e0280-6d2a-0410-9c65-932aecc39d9d
  • Loading branch information...
1 parent f461af3 commit b67753b68f42f5867bfb29cb4bee015546c9a6b3 ludvigm committed Jan 7, 2009
Showing with 21 additions and 3 deletions.
  1. +5 −0 ChangeLog
  2. +16 −3 S3/S3.py
View
@@ -1,3 +1,8 @@
+2009-01-08 Michal Ludvig <michal@logix.cz>
+
+ * S3/S3.py: Some errors during file upload were incorrectly
+ interpreted as MD5 mismatch. (bug #2384990)
+
2009-01-07 Michal Ludvig <michal@logix.cz>
* s3cmd: New command 'setacl'.
View
@@ -430,7 +430,7 @@ def send_file(self, request, file, labels, throttle = 0, retries = _max_retries)
md5_hash = md5()
try:
while (size_left > 0):
- debug("SendFile: Reading up to %d bytes from '%s'" % (self.config.send_chunk, file.name))
+ #debug("SendFile: Reading up to %d bytes from '%s'" % (self.config.send_chunk, file.name))
data = file.read(self.config.send_chunk)
md5_hash.update(data)
conn.send(data)
@@ -448,6 +448,7 @@ def send_file(self, request, file, labels, throttle = 0, retries = _max_retries)
response["data"] = http_response.read()
response["size"] = size_total
conn.close()
+ debug(u"Response: %s" % response)
except Exception, e:
if self.config.progress_meter:
progress.done("failed")
@@ -487,6 +488,20 @@ def send_file(self, request, file, labels, throttle = 0, retries = _max_retries)
if not response['headers'].has_key('etag'):
response['headers']['etag'] = ''
+ if response["status"] < 200 or response["status"] > 299:
+ if response["status"] >= 500:
+ ## AWS internal error - retry
+ if retries:
+ warning("Upload failed: %s (%s)" % (resource['uri'], S3Error(response)))
+ warning("Waiting %d sec..." % self._fail_wait(retries))
+ time.sleep(self._fail_wait(retries))
+ return self.send_file(request, file, labels, throttle, retries - 1)
+ else:
+ warning("Too many failures. Giving up on '%s'" % (file.name))
+ raise S3UploadError
+ ## Non-recoverable error
+ raise S3Error(response)
+
debug("MD5 sums: computed=%s, received=%s" % (md5_computed, response["headers"]["etag"]))
if response["headers"]["etag"].strip('"\'') != md5_hash.hexdigest():
warning("MD5 Sums don't match!")
@@ -497,8 +512,6 @@ def send_file(self, request, file, labels, throttle = 0, retries = _max_retries)
warning("Too many failures. Giving up on '%s'" % (file.name))
raise S3UploadError
- if response["status"] < 200 or response["status"] > 299:
- raise S3Error(response)
return response
def recv_file(self, request, stream, labels, start_position = 0, retries = _max_retries):

0 comments on commit b67753b

Please sign in to comment.