Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update AssetManager.cs #87

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 19 additions & 1 deletion LibreMetaverse/AssetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -823,7 +823,18 @@ private void RequestAssetHTTP(UUID assetID, AssetDownload transfer, AssetReceive
// If ViewerAsset capability exists, use that, if not, fallback to UDP
if (Client.Network.CurrentSim?.Caps?.CapabilityURI("ViewerAsset") != null)
{
RequestInventoryAssetHTTP(assetID, transfer, callback);
RequestInventoryAssetHTTP(assetID, transfer,
(AssetDownload transferResult, Asset assetResult) =>
{
if (transferResult.Success == false)
{
Logger.Log($"HTTP transfer has failed trying UDP", Helpers.LogLevel.Warning, Client);
RequestInventoryAssetUDP(assetID, itemID, taskID, ownerID, transfer, callback);
return;
}
callback(transferResult, assetResult);
}
);
}
else
{
Expand All @@ -842,6 +853,7 @@ private void RequestAssetHTTP(UUID assetID, AssetDownload transfer, AssetReceive
/// <param name="callback"></param>
private void RequestInventoryAssetHTTP(UUID assetID, AssetDownload transfer, AssetReceivedCallback callback)
{
int attempts = 0;
DownloadRequest req = new DownloadRequest(
BuildFetchRequestUri(transfer.AssetType, assetID),
null,
Expand All @@ -866,13 +878,19 @@ private void RequestInventoryAssetHTTP(UUID assetID, AssetDownload transfer, Ass
}
else // download failed
{
attempts++;
Logger.Log($"Failed to fetch asset {assetID}: {((error == null) ? "" : error.Message)}",
Helpers.LogLevel.Warning, Client);
if (callback != null)
{
transfer.Success = false;
transfer.Status = StatusCode.Error;
}
if (attempts == 5)
{
callback(transfer, null);
}


}
}
Expand Down