def verifySingleCommit(commit, bundle): with DebugInfo('Verify commit: %04d-%s' % (commit['CommitID'],commit['Name'])) as d: actualHash = recalculateCommitMD5(commit, bundle) expectHash = commit['MD5'] if actualHash != expectHash: from pclib import byteshex message = 'Verify failed: actual %s expect %s' % (byteshex.encode(actualHash), byteshex.encode(expectHash)) d.result = message return message else: d.result = 'Success'
def recalculateCommitMD5(commit, bundle): with DebugInfo('Recalculating commit md5') as d: from histo.server.get import openDataCodes from pclib import hashstream hasher = hashstream('md5') with openDataCodes(bundle, commit) as f: from pclib import copystream copystream(f, hasher) result = hasher.digest() from pclib import byteshex d.result = byteshex.encode(result) return result