mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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
1 changed files with 7 additions and 4 deletions
11
qthelper.cpp
11
qthelper.cpp
|
|
@ -819,10 +819,13 @@ QByteArray hashFile(const QString filename)
|
||||||
{
|
{
|
||||||
QCryptographicHash hash(QCryptographicHash::Sha1);
|
QCryptographicHash hash(QCryptographicHash::Sha1);
|
||||||
QFile imagefile(filename);
|
QFile imagefile(filename);
|
||||||
imagefile.open(QIODevice::ReadOnly);
|
if (imagefile.open(QIODevice::ReadOnly)) {
|
||||||
hash.addData(&imagefile);
|
hash.addData(&imagefile);
|
||||||
add_hash(filename, hash.result());
|
add_hash(filename, hash.result());
|
||||||
return hash.result();
|
return hash.result();
|
||||||
|
} else {
|
||||||
|
return QByteArray();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void learnHash(struct picture *picture, QByteArray hash)
|
void learnHash(struct picture *picture, QByteArray hash)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue