mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 18:50:00 +02:00
Update ResourceCache to retry an asset request when the node is unavailable
This commit is contained in:
parent
9575b47e4e
commit
c6d98f3c67
3 changed files with 18 additions and 0 deletions
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
#include "AssetClient.h"
|
#include "AssetClient.h"
|
||||||
#include "AssetRequest.h"
|
#include "AssetRequest.h"
|
||||||
|
#include "AssetUtils.h"
|
||||||
|
|
||||||
void AssetResourceRequest::doSend() {
|
void AssetResourceRequest::doSend() {
|
||||||
// Make request to atp
|
// Make request to atp
|
||||||
|
@ -21,9 +22,23 @@ void AssetResourceRequest::doSend() {
|
||||||
auto hash = parts[0];
|
auto hash = parts[0];
|
||||||
auto extension = parts.length() > 1 ? parts[1] : "";
|
auto extension = parts.length() > 1 ? parts[1] : "";
|
||||||
|
|
||||||
|
if (hash.length() != SHA256_HASH_HEX_LENGTH) {
|
||||||
|
_result = InvalidURL;
|
||||||
|
_state = Finished;
|
||||||
|
|
||||||
|
emit finished();
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
auto request = assetClient->createRequest(hash, extension);
|
auto request = assetClient->createRequest(hash, extension);
|
||||||
|
|
||||||
if (!request) {
|
if (!request) {
|
||||||
|
_result = ServerUnavailable;
|
||||||
|
_state = Finished;
|
||||||
|
|
||||||
|
emit finished();
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -396,6 +396,7 @@ void Resource::handleReplyFinished() {
|
||||||
bool retry = false;
|
bool retry = false;
|
||||||
switch (result) {
|
switch (result) {
|
||||||
case ResourceRequest::Result::Timeout:
|
case ResourceRequest::Result::Timeout:
|
||||||
|
case ResourceRequest::Result::ServerUnavailable:
|
||||||
case ResourceRequest::Result::Error: {
|
case ResourceRequest::Result::Error: {
|
||||||
// retry with increasing delays
|
// retry with increasing delays
|
||||||
const int MAX_ATTEMPTS = 8;
|
const int MAX_ATTEMPTS = 8;
|
||||||
|
|
|
@ -30,7 +30,9 @@ public:
|
||||||
Success,
|
Success,
|
||||||
Error,
|
Error,
|
||||||
Timeout,
|
Timeout,
|
||||||
|
ServerUnavailable,
|
||||||
AccessDenied,
|
AccessDenied,
|
||||||
|
InvalidURL,
|
||||||
NotFound
|
NotFound
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue