Skip to content

Commit

Permalink
Fixed handling of expected resumable upload error when file size chan…
Browse files Browse the repository at this point in the history
…ges during resumed upload.
  • Loading branch information
mfschwartz committed Jul 22, 2011
1 parent 294a250 commit e3f4915
Show file tree
Hide file tree
Showing 3 changed files with 742 additions and 2 deletions.
15 changes: 14 additions & 1 deletion boto/gs/resumable_upload_handler.py
Expand Up @@ -331,7 +331,20 @@ def _upload_file_bytes(self, conn, http_conn, fp, file_length,
# in debug stream.
http_conn.set_debuglevel(0)
while buf:
http_conn.send(buf)
try:
http_conn.send(buf)
except socket.error, e:
# The server will close the connection if you send more
# bytes in a resumed upload than the original file size.
if (e.args[0] == errno.EPIPE and
total_bytes_uploaded != file_length):
raise ResumableUploadException(
'File changed during upload: sent %d bytes for file for '
'which original size was %d bytes file.' %
(total_bytes_uploaded, file_length),
ResumableTransferDisposition.ABORT)
# Some other failure happened. Pass the exception on.
raise e
total_bytes_uploaded += len(buf)
if cb:
i += 1
Expand Down

0 comments on commit e3f4915

Please sign in to comment.