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:
parent
b27538feba
commit
2005723989
11
qthelper.cpp
11
qthelper.cpp
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user