libremetaverse
libremetaverse copied to clipboard
Assets.RequestInventoryAsset is broken for reading notecards [SL]
libremetaverse Known broken versions:
- 2.0.10.575
- 2.0.6.545
- 2.0.3.521
works on version:
- 1.9.17.425
Radegast
example code
public void NotecardToMem(string notecardUUID)
{
if (UUID.TryParse(notecardUUID, out UUID inventoryUUID) == false)
{
client.Self.Chat("Unable to read notecard UUID", 0, ChatType.Normal);
}
InventoryItem A = client.Inventory.FetchItem(inventoryUUID, client.Self.AgentID, 2000);
if (A == null)
{
client.Self.Chat("Unable to find notecard with UUID", 0, ChatType.Normal);
}
if(A.InventoryType != InventoryType.Notecard)
{
client.Self.Chat("Unable to find notecard with UUID", 0, ChatType.Normal);
}
var transferID = UUID.Random();
client.Assets.RequestInventoryAsset(
A,
true,
transferID,
(AssetDownload transfer, Asset asset) =>
{
if (transfer.Success && transfer.ID == transferID)
{
AssetNotecard n = (AssetNotecard)asset;
n.Decode();
AssetNotecard recievedNotecard = n;
string text = string.Empty;
for (int i = 0; i < n.BodyText.Length; i++)
{
char c = n.BodyText[i];
// Special marker for embedded things.
if ((int)c == 0xdbc0)
{
int index = (int)n.BodyText[++i] - 0xdc00;
InventoryItem e = n.EmbeddedItems[index];
text += " (embedded) ";
}
else
{
text += c;
}
}
client.Self.Chat(text, 0, ChatType.Normal);
}
else
{
client.Self.Chat("Transfer failed", 0, ChatType.Normal);
}
}
);
client.Self.Chat("working on it", 0, ChatType.Normal);
}
expected output: working on it "Hello world"
current results: Failed to fetch asset <UUID REMOVED>: BadRequest Bad Request
notes: if you request a asset that was loaded with the older version and then update to current and redo the request it works as expected.
worked around by: https://github.com/cinderblocks/libremetaverse/pull/87
Should be fixed as of 7df9068e