Only attempt to download each picture once

Otherwise we keep downloading the same image multiple times instead
of new images.

Signed-off-by: Robert C. Helling <helling@atdotde.de>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Robert C. Helling 2016-05-01 00:00:29 +02:00 committed by Dirk Hohndel
parent 4a9b97e4a9
commit c2c0cb48d2

View file

@ -4,6 +4,7 @@
#include "qthelper.h"
#include "imagedownloader.h"
#include <unistd.h>
#include <QString>
#include <QtConcurrent>
@ -75,10 +76,17 @@ void ImageDownloader::saveImage(QNetworkReply *reply)
}
QSet<QString> queuedPictures;
QMutex pictureQueueMutex;
void loadPicture(struct picture *picture, bool fromHash)
{
if (!picture)
return;
QMutexLocker locker(&pictureQueueMutex);
if (queuedPictures.contains(QString(picture->filename)))
return;
queuedPictures.insert(QString(picture->filename));
ImageDownloader download(picture);
download.load(fromHash);
}