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

Side by Side Diff: boto/s3/resumable_download_handler.py

Issue 9956052: Fix checksum support to be compatible with Windows. (Closed) Base URL: svn://svn.chromium.org/boto
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « README.chromium ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2010 Google Inc. 1 # Copyright 2010 Google Inc.
2 # 2 #
3 # Permission is hereby granted, free of charge, to any person obtaining a 3 # Permission is hereby granted, free of charge, to any person obtaining a
4 # copy of this software and associated documentation files (the 4 # copy of this software and associated documentation files (the
5 # "Software"), to deal in the Software without restriction, including 5 # "Software"), to deal in the Software without restriction, including
6 # without limitation the rights to use, copy, modify, merge, publish, dis- 6 # without limitation the rights to use, copy, modify, merge, publish, dis-
7 # tribute, sublicense, and/or sell copies of the Software, and to permit 7 # tribute, sublicense, and/or sell copies of the Software, and to permit
8 # persons to whom the Software is furnished to do so, subject to the fol- 8 # persons to whom the Software is furnished to do so, subject to the fol-
9 # lowing conditions: 9 # lowing conditions:
10 # 10 #
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 fp.flush() 213 fp.flush()
214 214
215 def _check_final_md5(self, key, file_name): 215 def _check_final_md5(self, key, file_name):
216 """ 216 """
217 Checks that etag from server agrees with md5 computed after the 217 Checks that etag from server agrees with md5 computed after the
218 download completes. This is important, since the download could 218 download completes. This is important, since the download could
219 have spanned a number of hours and multiple processes (e.g., 219 have spanned a number of hours and multiple processes (e.g.,
220 gsutil runs), and the user could change some of the file and not 220 gsutil runs), and the user could change some of the file and not
221 realize they have inconsistent data. 221 realize they have inconsistent data.
222 """ 222 """
223 fp = open(file_name, 'r') 223 fp = open(file_name, 'rb')
224 if key.bucket.connection.debug >= 1: 224 if key.bucket.connection.debug >= 1:
225 print 'Checking md5 against etag.' 225 print 'Checking md5 against etag.'
226 hex_md5 = key.compute_md5(fp)[0] 226 hex_md5 = key.compute_md5(fp)[0]
227 if hex_md5 != key.etag.strip('"\''): 227 if hex_md5 != key.etag.strip('"\''):
228 file_name = fp.name 228 file_name = fp.name
229 fp.close() 229 fp.close()
230 os.unlink(file_name) 230 os.unlink(file_name)
231 raise ResumableDownloadException( 231 raise ResumableDownloadException(
232 'File changed during download: md5 signature doesn\'t match ' 232 'File changed during download: md5 signature doesn\'t match '
233 'etag (incorrect downloaded file deleted)', 233 'etag (incorrect downloaded file deleted)',
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 key.close() 344 key.close()
345 except httplib.IncompleteRead: 345 except httplib.IncompleteRead:
346 pass 346 pass
347 347
348 sleep_time_secs = 2**progress_less_iterations 348 sleep_time_secs = 2**progress_less_iterations
349 if debug >= 1: 349 if debug >= 1:
350 print('Got retryable failure (%d progress-less in a row).\n' 350 print('Got retryable failure (%d progress-less in a row).\n'
351 'Sleeping %d seconds before re-trying' % 351 'Sleeping %d seconds before re-trying' %
352 (progress_less_iterations, sleep_time_secs)) 352 (progress_less_iterations, sleep_time_secs))
353 time.sleep(sleep_time_secs) 353 time.sleep(sleep_time_secs)
OLDNEW
« no previous file with comments | « README.chromium ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698