We actually get a free request if we hit a cached image.

This commit is contained in:
Lukas Brübach 2025-06-12 00:26:24 +02:00
parent 464ab2b0da
commit 2dd3a90243
2 changed files with 9 additions and 0 deletions

View file

@ -111,6 +111,14 @@ QNetworkReply *PictureLoaderWorker::makeRequest(const QUrl &url, PictureLoaderWo
if (reply->error() == QNetworkReply::NoError) { if (reply->error() == QNetworkReply::NoError) {
worker->picDownloadFinished(reply); worker->picDownloadFinished(reply);
emit imageLoadSuccessful(url, worker); emit imageLoadSuccessful(url, worker);
// If we hit a cached image, we get to make another request for free.
if (reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute).toBool()) {
if (!requestLoadQueue.isEmpty()) {
auto request = requestLoadQueue.takeFirst();
makeRequest(request.first, request.second);
}
}
} else if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 429) { } else if (reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt() == 429) {
qInfo() << "Too many requests."; qInfo() << "Too many requests.";
} }

View file

@ -21,6 +21,7 @@ set(oracle_SOURCES
../cockatrice/src/game/cards/card_database_manager.cpp ../cockatrice/src/game/cards/card_database_manager.cpp
../cockatrice/src/game/cards/card_info.cpp ../cockatrice/src/game/cards/card_info.cpp
../cockatrice/src/client/ui/picture_loader/picture_loader.cpp ../cockatrice/src/client/ui/picture_loader/picture_loader.cpp
../cockatrice/src/client/ui/picture_loader/picture_loader_request_status_display_widget.cpp
../cockatrice/src/client/ui/picture_loader/picture_loader_status_bar.cpp ../cockatrice/src/client/ui/picture_loader/picture_loader_status_bar.cpp
../cockatrice/src/client/ui/picture_loader/picture_loader_worker.cpp ../cockatrice/src/client/ui/picture_loader/picture_loader_worker.cpp
../cockatrice/src/client/ui/picture_loader/picture_loader_worker_work.cpp ../cockatrice/src/client/ui/picture_loader/picture_loader_worker_work.cpp