fix random file verifier with small files

The file verifier will now correctly verify small files (smaller than
the md5 digest size), as long as the data that is there matches what
the digest would be.
This commit is contained in:
Steven Berler 2011-07-13 13:50:26 -07:00
parent 91a39caf46
commit 91c4f88860

View file

@ -78,6 +78,9 @@ class FileVerifier(object):
Returns True if this file looks valid. The file is valid if the end
of the file has the md5 digest for the first part of the file.
"""
if self.size < self.hash.digest_size:
return self.hash.digest().startswith(self.buf)
return self.buf == self.hash.digest()
def files(mean, stddev, seed=None):