Log download failures
This commit is contained in:
parent
632e7f487c
commit
0420f4f7af
2 changed files with 10 additions and 8 deletions
|
@ -132,7 +132,7 @@ void PictureLoader::processLoadQueue()
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
emit imageLoaded(ptl.getCard(), image);
|
emit imageLoaded(ptl.getCard(), image);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,6 +176,10 @@ void PictureLoader::startNextPicDownload()
|
||||||
void PictureLoader::picDownloadFinished(QNetworkReply *reply)
|
void PictureLoader::picDownloadFinished(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
QString picsPath = _picsPath;
|
QString picsPath = _picsPath;
|
||||||
|
if (reply->error()) {
|
||||||
|
qDebug() << "Download failed:" << reply->errorString();
|
||||||
|
}
|
||||||
|
|
||||||
const QByteArray &picData = reply->readAll();
|
const QByteArray &picData = reply->readAll();
|
||||||
QImage testImage;
|
QImage testImage;
|
||||||
if (testImage.loadFromData(picData)) {
|
if (testImage.loadFromData(picData)) {
|
||||||
|
@ -189,17 +193,17 @@ void PictureLoader::picDownloadFinished(QNetworkReply *reply)
|
||||||
QDir dir(QString(picsPath + "/downloadedPics"));
|
QDir dir(QString(picsPath + "/downloadedPics"));
|
||||||
dir.mkdir(cardBeingDownloaded.getSetName());
|
dir.mkdir(cardBeingDownloaded.getSetName());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString suffix;
|
QString suffix;
|
||||||
if (!cardBeingDownloaded.getStripped())
|
if (!cardBeingDownloaded.getStripped())
|
||||||
suffix = ".full";
|
suffix = ".full";
|
||||||
|
|
||||||
QFile newPic(picsPath + "/downloadedPics/" + cardBeingDownloaded.getSetName() + "/" + cardBeingDownloaded.getCard()->getCorrectedName() + suffix + ".jpg");
|
QFile newPic(picsPath + "/downloadedPics/" + cardBeingDownloaded.getSetName() + "/" + cardBeingDownloaded.getCard()->getCorrectedName() + suffix + ".jpg");
|
||||||
if (!newPic.open(QIODevice::WriteOnly))
|
if (!newPic.open(QIODevice::WriteOnly))
|
||||||
return;
|
return;
|
||||||
newPic.write(picData);
|
newPic.write(picData);
|
||||||
newPic.close();
|
newPic.close();
|
||||||
|
|
||||||
emit imageLoaded(cardBeingDownloaded.getCard(), testImage);
|
emit imageLoaded(cardBeingDownloaded.getCard(), testImage);
|
||||||
} else if (cardBeingDownloaded.getHq()) {
|
} else if (cardBeingDownloaded.getHq()) {
|
||||||
qDebug() << "HQ: received invalid picture. URL:" << reply->request().url();
|
qDebug() << "HQ: received invalid picture. URL:" << reply->request().url();
|
||||||
|
@ -216,7 +220,7 @@ void PictureLoader::picDownloadFinished(QNetworkReply *reply)
|
||||||
} else
|
} else
|
||||||
emit imageLoaded(cardBeingDownloaded.getCard(), QImage());
|
emit imageLoaded(cardBeingDownloaded.getCard(), QImage());
|
||||||
}
|
}
|
||||||
|
|
||||||
reply->deleteLater();
|
reply->deleteLater();
|
||||||
startNextPicDownload();
|
startNextPicDownload();
|
||||||
}
|
}
|
||||||
|
@ -224,7 +228,7 @@ void PictureLoader::picDownloadFinished(QNetworkReply *reply)
|
||||||
void PictureLoader::loadImage(CardInfo *card, bool stripped)
|
void PictureLoader::loadImage(CardInfo *card, bool stripped)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
|
|
||||||
loadQueue.append(PictureToLoad(card, stripped));
|
loadQueue.append(PictureToLoad(card, stripped));
|
||||||
emit startLoadQueue();
|
emit startLoadQueue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,10 +53,8 @@ public:
|
||||||
bool getStripped() const { return stripped; }
|
bool getStripped() const { return stripped; }
|
||||||
QString getSetName() const { return sortedSets[setIndex]->getShortName(); }
|
QString getSetName() const { return sortedSets[setIndex]->getShortName(); }
|
||||||
bool nextSet();
|
bool nextSet();
|
||||||
|
|
||||||
bool getHq() const { return hq; }
|
bool getHq() const { return hq; }
|
||||||
void setHq(bool _hq) { hq = _hq; }
|
void setHq(bool _hq) { hq = _hq; }
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class PictureLoader : public QObject {
|
class PictureLoader : public QObject {
|
||||||
|
|
Loading…
Reference in a new issue