Dive pictures: remove hashes

In the last commits, the canonical-to-local filename map was made
independent from the image hashes and the location of moved images
was based on filename not hashes. The hashes are now in principle
unused (except for conversion of old-style local filename lookups).

Therefore, remove the hashes in this commit. This makes addition
of images distinctly faster.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-06-10 16:39:47 +02:00 committed by Dirk Hohndel
parent 0646b41275
commit f3ef38ca0d
11 changed files with 32 additions and 122 deletions

View file

@ -61,7 +61,6 @@ void ImageDownloader::saveImage(QNetworkReply *reply)
imageFile.waitForBytesWritten(-1);
imageFile.close();
learnPictureFilename(filename, imageFile.fileName());
hashPicture(filename); // hashPicture transforms canonical into local filename
}
emit loaded(filename);
}
@ -83,10 +82,6 @@ static std::pair<QImage, bool> fetchImage(const QString &filename, const QString
QUrl url = QUrl::fromUserInput(filename);
if (url.isLocalFile()) {
thumb.load(url.toLocalFile());
// If we loaded successfully, make sure the hash is up to date.
// Note that hashPicture() takes the *original* filename.
if (!thumb.isNull())
hashPicture(originalFilename);
} else if (tryDownload) {
// This has to be done in UI main thread, because QNetworkManager refuses
// to treat requests from other threads. invokeMethod() is Qt's way of calling a
@ -247,8 +242,7 @@ void Thumbnailer::processItem(QString filename, bool tryDownload)
void Thumbnailer::imageDownloaded(QString filename)
{
// Image was downloaded and the filename connected with a hash.
// Try thumbnailing again.
// Image was downloaded -> try thumbnailing again.
QMutexLocker l(&lock);
workingOn[filename] = QtConcurrent::run(&pool, [this, filename]() { processItem(filename, false); });
}