mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Dive pictures: Derive thumbnail file from picture filename
Since commit 6618c9ebfc
, thumbnails
are saved in individual files. The filename was simply the picture-hash.
In a mailing-list discussion it turned out that in the future we might
not hash images or change the hash. Therefore, derive the thumbnail
filename from the image filename, using the SHA1 algorithm.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
b34eeeaba2
commit
80224a98b1
2 changed files with 6 additions and 13 deletions
|
@ -1088,12 +1088,14 @@ static QString thumbnailDir()
|
|||
return QString(system_default_directory()) + "/thumbnails/";
|
||||
}
|
||||
|
||||
// Return filename of thumbnail if it is known to us.
|
||||
// If this is an unknown thumbnail, return an empty string.
|
||||
// Calculate thumbnail filename by hashing name of file.
|
||||
QString thumbnailFileName(const QString &filename)
|
||||
{
|
||||
QString hash = getHash(filename).toHex();
|
||||
return hash.isEmpty() ? QString() : thumbnailDir() + hash;
|
||||
if (filename.isEmpty())
|
||||
return QString();
|
||||
QCryptographicHash hash(QCryptographicHash::Sha1);
|
||||
hash.addData(filename.toUtf8());
|
||||
return thumbnailDir() + hash.result().toHex();
|
||||
}
|
||||
|
||||
extern "C" char *hashfile_name_string()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue