Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Unified Diff: third_party/gsutil/boto/boto/s3/resumable_download_handler.py

Issue 10199002: Upgrade gsutil to 3.4 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed comments Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/gsutil/boto/boto/s3/prefix.py ('k') | third_party/gsutil/boto/boto/s3/user.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/gsutil/boto/boto/s3/resumable_download_handler.py
diff --git a/third_party/gsutil/20110627/boto/boto/s3/resumable_download_handler.py b/third_party/gsutil/boto/boto/s3/resumable_download_handler.py
similarity index 93%
rename from third_party/gsutil/20110627/boto/boto/s3/resumable_download_handler.py
rename to third_party/gsutil/boto/boto/s3/resumable_download_handler.py
index 42c87332f05bf16cf6369b643d79433cfdb841b1..ffa209575c42e164d03a9331e75e26871ab9ab99 100644
--- a/third_party/gsutil/20110627/boto/boto/s3/resumable_download_handler.py
+++ b/third_party/gsutil/boto/boto/s3/resumable_download_handler.py
@@ -212,27 +212,6 @@ class ResumableDownloadHandler(object):
override_num_retries=0)
fp.flush()
- def _check_final_md5(self, key, file_name):
- """
- Checks that etag from server agrees with md5 computed after the
- download completes. This is important, since the download could
- have spanned a number of hours and multiple processes (e.g.,
- gsutil runs), and the user could change some of the file and not
- realize they have inconsistent data.
- """
- fp = open(file_name, 'r')
- if key.bucket.connection.debug >= 1:
- print 'Checking md5 against etag.'
- hex_md5 = key.compute_md5(fp)[0]
- if hex_md5 != key.etag.strip('"\''):
- file_name = fp.name
- fp.close()
- os.unlink(file_name)
- raise ResumableDownloadException(
- 'File changed during download: md5 signature doesn\'t match '
- 'etag (incorrect downloaded file deleted)',
- ResumableTransferDisposition.ABORT)
-
def get_file(self, key, fp, headers, cb=None, num_cb=10, torrent=False,
version_id=None):
"""
@@ -287,7 +266,10 @@ class ResumableDownloadHandler(object):
torrent, version_id)
# Download succceded, so remove the tracker file (if have one).
self._remove_tracker_file()
- self._check_final_md5(key, fp.name)
+ # Previously, check_final_md5() was called here to validate
+ # downloaded file's checksum, however, to be consistent with
+ # non-resumable downloads, this call was removed. Checksum
+ # validation of file contents should be done by the caller.
if debug >= 1:
print 'Resumable download complete.'
return
@@ -336,7 +318,14 @@ class ResumableDownloadHandler(object):
# Close the key, in case a previous download died partway
# through and left data in the underlying key HTTP buffer.
- key.close()
+ # Do this within a try/except block in case the connection is
+ # closed (since key.close() attempts to do a final read, in which
+ # case this read attempt would get an IncompleteRead exception,
+ # which we can safely ignore.
+ try:
+ key.close()
+ except httplib.IncompleteRead:
+ pass
sleep_time_secs = 2**progress_less_iterations
if debug >= 1:
« no previous file with comments | « third_party/gsutil/boto/boto/s3/prefix.py ('k') | third_party/gsutil/boto/boto/s3/user.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698