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

Side by Side Diff: native_client_sdk/src/build_tools/sdk_tools/command/update.py

Issue 1413663005: Do not fail checksum check before download (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding myself to chromium/AUTHORS Created 5 years, 2 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
« no previous file with comments | « native_client_sdk/src/AUTHORS ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import hashlib 5 import hashlib
6 import copy 6 import copy
7 import logging 7 import logging
8 import os 8 import os
9 import subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 filename = os.path.join(self.archive_cache, filename) 67 filename = os.path.join(self.archive_cache, filename)
68 if not os.path.exists(filename): 68 if not os.path.exists(filename):
69 logging.info('File does not exist: %s.' % filename) 69 logging.info('File does not exist: %s.' % filename)
70 return False 70 return False
71 size = os.path.getsize(filename) 71 size = os.path.getsize(filename)
72 if size != archive.size: 72 if size != archive.size:
73 logging.info('File size does not match (%d vs %d): %s.' % (size, 73 logging.info('File size does not match (%d vs %d): %s.' % (size,
74 archive.size, filename)) 74 archive.size, filename))
75 return False 75 return False
76 sha1_hash = hashlib.sha1() 76 sha1_hash = hashlib.sha1()
77 with open(filename) as f: 77 with open(filename, 'rb') as f:
78 sha1_hash.update(f.read()) 78 sha1_hash.update(f.read())
79 if sha1_hash.hexdigest() != archive.GetChecksum(): 79 if sha1_hash.hexdigest() != archive.GetChecksum():
80 logging.info('File hash does not match: %s.' % filename) 80 logging.info('File hash does not match: %s.' % filename)
81 return False 81 return False
82 return True 82 return True
83 83
84 def BytesUsedInCache(self): 84 def BytesUsedInCache(self):
85 """Determine number of bytes currently be in local archive cache.""" 85 """Determine number of bytes currently be in local archive cache."""
86 total = 0 86 total = 0
87 for root, _, files in os.walk(self.archive_cache): 87 for root, _, files in os.walk(self.archive_cache):
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 return os.path.basename(path) 380 return os.path.basename(path)
381 381
382 382
383 def _ValidateArchive(archive, actual_sha1, actual_size): 383 def _ValidateArchive(archive, actual_sha1, actual_size):
384 if actual_size != archive.size: 384 if actual_size != archive.size:
385 raise Error('Size mismatch on "%s". Expected %s but got %s bytes' % ( 385 raise Error('Size mismatch on "%s". Expected %s but got %s bytes' % (
386 archive.url, archive.size, actual_size)) 386 archive.url, archive.size, actual_size))
387 if actual_sha1 != archive.GetChecksum(): 387 if actual_sha1 != archive.GetChecksum():
388 raise Error('SHA1 checksum mismatch on "%s". Expected %s but got %s' % ( 388 raise Error('SHA1 checksum mismatch on "%s". Expected %s but got %s' % (
389 archive.url, archive.GetChecksum(), actual_sha1)) 389 archive.url, archive.GetChecksum(), actual_sha1))
OLDNEW
« no previous file with comments | « native_client_sdk/src/AUTHORS ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698