It isn't used much compared to what the methodname suggests, but in the
remaining uses it can't hurt to check more than strictly necessary by
calculating and verifying with all hashes we can compare with rather
than "just" the best known hash.
else if (State == StateApplyDiff)
{
// see if we really got the expected file
else if (State == StateApplyDiff)
{
// see if we really got the expected file
- if(ExpectedHashes.usable() && !ExpectedHashes.VerifyFile(DestFile))
+ if(ExpectedHashes.usable() && ExpectedHashes != Hashes)
{
RenameOnError(HashSumMismatch);
return;
{
RenameOnError(HashSumMismatch);
return;
/*}}}*/
bool HashStringList::VerifyFile(std::string filename) const /*{{{*/
{
/*}}}*/
bool HashStringList::VerifyFile(std::string filename) const /*{{{*/
{
- if (list.empty() == true)
- return false;
- HashString const * const hs = find(NULL);
- if (hs == NULL || hs->VerifyFile(filename) == false)
+
+ Hashes hashes(*this);
+ FileFd file(filename, FileFd::ReadOnly);
HashString const * const hsf = find("Checksum-FileSize");
HashString const * const hsf = find("Checksum-FileSize");
- if (hsf != NULL && hsf->VerifyFile(filename) == false)
- return false;
- return true;
+ if (hsf != NULL)
+ {
+ std::string fileSize;
+ strprintf(fileSize, "%llu", file.FileSize());
+ if (hsf->HashValue() != fileSize)
+ return false;
+ }
+ hashes.AddFD(file);
+ HashStringList const hsl = hashes.GetHashStringList();
+ return hsl == *this;
}
/*}}}*/
bool HashStringList::operator==(HashStringList const &other) const /*{{{*/
}
/*}}}*/
bool HashStringList::operator==(HashStringList const &other) const /*{{{*/