Show More
@@ -373,11 +373,8 b' def copyandhash(instream, outfile):' | |||||
373 | def hashfile(file): |
|
373 | def hashfile(file): | |
374 | if not os.path.exists(file): |
|
374 | if not os.path.exists(file): | |
375 | return '' |
|
375 | return '' | |
376 | hasher = hashlib.sha1('') |
|
|||
377 | with open(file, 'rb') as fd: |
|
376 | with open(file, 'rb') as fd: | |
378 | for data in util.filechunkiter(fd): |
|
377 | return hexsha1(fd) | |
379 | hasher.update(data) |
|
|||
380 | return hasher.hexdigest() |
|
|||
381 |
|
378 | |||
382 | def getexecutable(filename): |
|
379 | def getexecutable(filename): | |
383 | mode = os.stat(filename).st_mode |
|
380 | mode = os.stat(filename).st_mode | |
@@ -398,11 +395,11 b' def urljoin(first, second, *arg):' | |||||
398 | url = join(url, a) |
|
395 | url = join(url, a) | |
399 | return url |
|
396 | return url | |
400 |
|
397 | |||
401 |
def hexsha1( |
|
398 | def hexsha1(fileobj): | |
402 | """hexsha1 returns the hex-encoded sha1 sum of the data in the file-like |
|
399 | """hexsha1 returns the hex-encoded sha1 sum of the data in the file-like | |
403 | object data""" |
|
400 | object data""" | |
404 | h = hashlib.sha1() |
|
401 | h = hashlib.sha1() | |
405 |
for chunk in util.filechunkiter( |
|
402 | for chunk in util.filechunkiter(fileobj): | |
406 | h.update(chunk) |
|
403 | h.update(chunk) | |
407 | return h.hexdigest() |
|
404 | return h.hexdigest() | |
408 |
|
405 |
General Comments 0
You need to be logged in to leave comments.
Login now