Make helper function deal with files that don't exist

Ignoring when you can't open a file and happily hashing its contents seems
wrong.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-06-21 10:25:53 -07:00
parent b27538feba
commit 2005723989

View file

@ -819,10 +819,13 @@ QByteArray hashFile(const QString filename)
{
QCryptographicHash hash(QCryptographicHash::Sha1);
QFile imagefile(filename);
imagefile.open(QIODevice::ReadOnly);
hash.addData(&imagefile);
add_hash(filename, hash.result());
return hash.result();
if (imagefile.open(QIODevice::ReadOnly)) {
hash.addData(&imagefile);
add_hash(filename, hash.result());
return hash.result();
} else {
return QByteArray();
}
}
void learnHash(struct picture *picture, QByteArray hash)