From Justin Casey (IBM)
While exploring what it would take to get the 'new script' button working, I encountered the fact, some way down in the rabbit hole, that if a user renamed an item in their inventory and logged out (without a restart of the simulator), on log in the new name was not preserved. As far as I can see, this was because any updates which didn't occur inside a transaction were ignored by opensim. This patch pays attention to those changes. It generates a new asset when an item is updated and changes the user's inventory properties appropriately. I believe this behaviour is in line with the copy-on-write semantics used in the Second Life protocol - perhaps it could be optimized if we knew for sure that the only copy of the object was in the user's inventory. This also means that if you rename an item (e.g. a script) before you drag it into an object's inventory, the inventory will receive the item's most recent name and description.afrisby
parent
5061808afc
commit
8f58a9a107
|
@ -310,8 +310,9 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
public delegate void RequestTaskInventory(IClientAPI remoteClient, uint localID);
|
public delegate void RequestTaskInventory(IClientAPI remoteClient, uint localID);
|
||||||
|
|
||||||
public delegate void UpdateInventoryItemTransaction(
|
public delegate void UpdateInventoryItem(
|
||||||
IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID);
|
IClientAPI remoteClient, LLUUID transactionID, LLUUID itemID, string name, string description,
|
||||||
|
uint nextOwnerMask);
|
||||||
|
|
||||||
public delegate void CopyInventoryItem(
|
public delegate void CopyInventoryItem(
|
||||||
IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName);
|
IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName);
|
||||||
|
@ -392,7 +393,7 @@ namespace OpenSim.Framework
|
||||||
event FetchInventoryDescendents OnFetchInventoryDescendents;
|
event FetchInventoryDescendents OnFetchInventoryDescendents;
|
||||||
event FetchInventory OnFetchInventory;
|
event FetchInventory OnFetchInventory;
|
||||||
event RequestTaskInventory OnRequestTaskInventory;
|
event RequestTaskInventory OnRequestTaskInventory;
|
||||||
event UpdateInventoryItemTransaction OnUpdateInventoryItem;
|
event UpdateInventoryItem OnUpdateInventoryItem;
|
||||||
event CopyInventoryItem OnCopyInventoryItem;
|
event CopyInventoryItem OnCopyInventoryItem;
|
||||||
event UDPAssetUploadRequest OnAssetUploadRequest;
|
event UDPAssetUploadRequest OnAssetUploadRequest;
|
||||||
event XferReceive OnXferReceive;
|
event XferReceive OnXferReceive;
|
||||||
|
@ -418,6 +419,8 @@ namespace OpenSim.Framework
|
||||||
|
|
||||||
LLUUID SessionId { get; }
|
LLUUID SessionId { get; }
|
||||||
|
|
||||||
|
LLUUID SecureSessionId { get; }
|
||||||
|
|
||||||
string FirstName { get; }
|
string FirstName { get; }
|
||||||
|
|
||||||
string LastName { get; }
|
string LastName { get; }
|
||||||
|
|
|
@ -59,7 +59,14 @@ namespace OpenSim.Region.ClientStack
|
||||||
//local handlers for this instance
|
//local handlers for this instance
|
||||||
|
|
||||||
private LLUUID m_sessionId;
|
private LLUUID m_sessionId;
|
||||||
public LLUUID SecureSessionID = LLUUID.Zero;
|
|
||||||
|
private LLUUID m_secureSessionId = LLUUID.Zero;
|
||||||
|
|
||||||
|
public LLUUID SecureSessionId
|
||||||
|
{
|
||||||
|
get { return m_secureSessionId; }
|
||||||
|
}
|
||||||
|
|
||||||
public string firstName;
|
public string firstName;
|
||||||
public string lastName;
|
public string lastName;
|
||||||
private UseCircuitCodePacket cirpack;
|
private UseCircuitCodePacket cirpack;
|
||||||
|
@ -540,7 +547,7 @@ namespace OpenSim.Region.ClientStack
|
||||||
|
|
||||||
if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero)
|
if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero)
|
||||||
{
|
{
|
||||||
SecureSessionID = sessionInfo.LoginInfo.SecureSession;
|
m_secureSessionId = sessionInfo.LoginInfo.SecureSession;
|
||||||
}
|
}
|
||||||
InitNewClient();
|
InitNewClient();
|
||||||
|
|
||||||
|
@ -615,7 +622,7 @@ namespace OpenSim.Region.ClientStack
|
||||||
public event FetchInventoryDescendents OnFetchInventoryDescendents;
|
public event FetchInventoryDescendents OnFetchInventoryDescendents;
|
||||||
public event FetchInventory OnFetchInventory;
|
public event FetchInventory OnFetchInventory;
|
||||||
public event RequestTaskInventory OnRequestTaskInventory;
|
public event RequestTaskInventory OnRequestTaskInventory;
|
||||||
public event UpdateInventoryItemTransaction OnUpdateInventoryItem;
|
public event UpdateInventoryItem OnUpdateInventoryItem;
|
||||||
public event CopyInventoryItem OnCopyInventoryItem;
|
public event CopyInventoryItem OnCopyInventoryItem;
|
||||||
public event UDPAssetUploadRequest OnAssetUploadRequest;
|
public event UDPAssetUploadRequest OnAssetUploadRequest;
|
||||||
public event XferReceive OnXferReceive;
|
public event XferReceive OnXferReceive;
|
||||||
|
@ -888,7 +895,7 @@ namespace OpenSim.Region.ClientStack
|
||||||
AgentCircuitData agentData = new AgentCircuitData();
|
AgentCircuitData agentData = new AgentCircuitData();
|
||||||
agentData.AgentID = AgentId;
|
agentData.AgentID = AgentId;
|
||||||
agentData.SessionID = m_sessionId;
|
agentData.SessionID = m_sessionId;
|
||||||
agentData.SecureSessionID = SecureSessionID;
|
agentData.SecureSessionID = SecureSessionId;
|
||||||
agentData.circuitcode = m_circuitCode;
|
agentData.circuitcode = m_circuitCode;
|
||||||
agentData.child = false;
|
agentData.child = false;
|
||||||
agentData.firstname = firstName;
|
agentData.firstname = firstName;
|
||||||
|
@ -2953,10 +2960,10 @@ namespace OpenSim.Region.ClientStack
|
||||||
case PacketType.AssetUploadRequest:
|
case PacketType.AssetUploadRequest:
|
||||||
AssetUploadRequestPacket request = (AssetUploadRequestPacket) Pack;
|
AssetUploadRequestPacket request = (AssetUploadRequestPacket) Pack;
|
||||||
// Console.WriteLine("upload request " + Pack.ToString());
|
// Console.WriteLine("upload request " + Pack.ToString());
|
||||||
// Console.WriteLine("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionID).ToStringHyphenated());
|
// Console.WriteLine("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToStringHyphenated());
|
||||||
if (OnAssetUploadRequest != null)
|
if (OnAssetUploadRequest != null)
|
||||||
{
|
{
|
||||||
OnAssetUploadRequest(this, request.AssetBlock.TransactionID.Combine(SecureSessionID),
|
OnAssetUploadRequest(this, request.AssetBlock.TransactionID.Combine(SecureSessionId),
|
||||||
request.AssetBlock.TransactionID, request.AssetBlock.Type,
|
request.AssetBlock.TransactionID, request.AssetBlock.Type,
|
||||||
request.AssetBlock.AssetData, request.AssetBlock.StoreLocal);
|
request.AssetBlock.AssetData, request.AssetBlock.StoreLocal);
|
||||||
}
|
}
|
||||||
|
@ -3033,12 +3040,11 @@ namespace OpenSim.Region.ClientStack
|
||||||
{
|
{
|
||||||
for (int i = 0; i < update.InventoryData.Length; i++)
|
for (int i = 0; i < update.InventoryData.Length; i++)
|
||||||
{
|
{
|
||||||
if (update.InventoryData[i].TransactionID != LLUUID.Zero)
|
OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID,
|
||||||
{
|
update.InventoryData[i].ItemID,
|
||||||
OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID,
|
Util.FieldToString(update.InventoryData[i].Name),
|
||||||
update.InventoryData[i].TransactionID.Combine(SecureSessionID),
|
Util.FieldToString(update.InventoryData[i].Description),
|
||||||
update.InventoryData[i].ItemID);
|
update.InventoryData[i].NextOwnerMask);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//Console.WriteLine(Pack.ToString());
|
//Console.WriteLine(Pack.ToString());
|
||||||
|
@ -3046,7 +3052,7 @@ namespace OpenSim.Region.ClientStack
|
||||||
{
|
{
|
||||||
if (update.InventoryData[i].TransactionID != LLUUID.Zero)
|
if (update.InventoryData[i].TransactionID != LLUUID.Zero)
|
||||||
{
|
{
|
||||||
AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID));
|
AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionId));
|
||||||
if (asset != null)
|
if (asset != null)
|
||||||
{
|
{
|
||||||
// Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache");
|
// Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache");
|
||||||
|
|
|
@ -106,52 +106,107 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
return LLUUID.Zero;
|
return LLUUID.Zero;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID,
|
/// <summary>
|
||||||
LLUUID itemID)
|
/// Update an item which is either already in the client's inventory or is within
|
||||||
|
/// a transaction
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="remoteClient"></param>
|
||||||
|
/// <param name="transactionID">The transaction ID. If this is LLUUID.Zero we will
|
||||||
|
/// assume that we are not in a transaction</param>
|
||||||
|
/// <param name="itemID">The ID of the updated item</param>
|
||||||
|
/// <param name="name">The name of the updated item</param>
|
||||||
|
/// <param name="description">The description of the updated item</param>
|
||||||
|
/// <param name="nextOwnerMask">The permissions of the updated item</param>
|
||||||
|
public void UpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID,
|
||||||
|
LLUUID itemID, string name, string description,
|
||||||
|
uint nextOwnerMask)
|
||||||
{
|
{
|
||||||
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
|
CachedUserInfo userInfo
|
||||||
if (userInfo != null)
|
= CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
|
||||||
|
|
||||||
|
if (userInfo != null && userInfo.RootFolder != null)
|
||||||
{
|
{
|
||||||
if (userInfo.RootFolder != null)
|
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
|
||||||
|
if (item != null)
|
||||||
{
|
{
|
||||||
InventoryItemBase item = userInfo.RootFolder.HasItem(itemID);
|
AssetBase asset = null;
|
||||||
if (item != null)
|
bool addAsset = false;
|
||||||
|
|
||||||
|
// If we're not inside a transaction and an existing asset is attached
|
||||||
|
// to the update item, then we need to create a new asset for the new details
|
||||||
|
if (LLUUID.Zero == transactionID)
|
||||||
{
|
{
|
||||||
AgentAssetTransactions transactions =
|
asset = AssetCache.GetAsset(item.assetID);
|
||||||
CommsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId);
|
|
||||||
|
if (asset != null)
|
||||||
|
{
|
||||||
|
// to update an item we need to create a new asset
|
||||||
|
// it's possible that this could be optimized to an update if we knew
|
||||||
|
// that the owner's inventory had the only copy of the item (I believe
|
||||||
|
// we're using copy on write semantics).
|
||||||
|
item.inventoryName = asset.Name = name;
|
||||||
|
item.inventoryDescription = asset.Description = description;
|
||||||
|
item.inventoryNextPermissions = nextOwnerMask;
|
||||||
|
item.assetID = asset.FullID = LLUUID.Random();
|
||||||
|
|
||||||
|
addAsset = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OpenSim.Framework.Console.MainLog.Instance.Warn(
|
||||||
|
"Asset ID " + item.assetID + " not found for item ID " + itemID
|
||||||
|
+ " named " + item.inventoryName + " for an inventory item update.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
AgentAssetTransactions transactions
|
||||||
|
= CommsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId);
|
||||||
|
|
||||||
if (transactions != null)
|
if (transactions != null)
|
||||||
{
|
{
|
||||||
AssetBase asset = null;
|
LLUUID assetID = transactionID.Combine(remoteClient.SecureSessionId);
|
||||||
bool addToCache = false;
|
|
||||||
|
|
||||||
asset = AssetCache.GetAsset(assetID);
|
asset = AssetCache.GetAsset(assetID);
|
||||||
|
|
||||||
if (asset == null)
|
if (asset == null)
|
||||||
{
|
{
|
||||||
asset = transactions.GetTransactionAsset(transactionID);
|
asset = transactions.GetTransactionAsset(transactionID);
|
||||||
addToCache = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (asset != null)
|
if (asset != null && asset.FullID == assetID)
|
||||||
{
|
{
|
||||||
if (asset.FullID == assetID)
|
asset.Name = item.inventoryName;
|
||||||
{
|
asset.Description = item.inventoryDescription;
|
||||||
asset.Name = item.inventoryName;
|
asset.InvType = (sbyte) item.invType;
|
||||||
asset.Description = item.inventoryDescription;
|
asset.Type = (sbyte) item.assetType;
|
||||||
asset.InvType = (sbyte) item.invType;
|
item.assetID = asset.FullID;
|
||||||
asset.Type = (sbyte) item.assetType;
|
|
||||||
item.assetID = asset.FullID;
|
|
||||||
|
|
||||||
if (addToCache)
|
addAsset = true;
|
||||||
{
|
|
||||||
AssetCache.AddAsset(asset);
|
|
||||||
}
|
|
||||||
|
|
||||||
userInfo.UpdateItem(remoteClient.AgentId, item);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (asset != null)
|
||||||
|
{
|
||||||
|
if (addAsset)
|
||||||
|
{
|
||||||
|
AssetCache.AddAsset(asset);
|
||||||
|
}
|
||||||
|
|
||||||
|
userInfo.UpdateItem(remoteClient.AgentId, item);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OpenSim.Framework.Console.MainLog.Instance.Warn(
|
||||||
|
"Item ID " + itemID + " not found for an inventory item update.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OpenSim.Framework.Console.MainLog.Instance.Warn(
|
||||||
|
"Agent ID " + remoteClient.AgentId + " not found for an inventory item update.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -989,7 +989,7 @@ namespace OpenSim.Region.Environment.Scenes
|
||||||
client.OnFetchInventoryDescendents += CommsManager.UserProfileCacheService.HandleFecthInventoryDescendents;
|
client.OnFetchInventoryDescendents += CommsManager.UserProfileCacheService.HandleFecthInventoryDescendents;
|
||||||
client.OnRequestTaskInventory += RequestTaskInventory;
|
client.OnRequestTaskInventory += RequestTaskInventory;
|
||||||
client.OnFetchInventory += CommsManager.UserProfileCacheService.HandleFetchInventory;
|
client.OnFetchInventory += CommsManager.UserProfileCacheService.HandleFetchInventory;
|
||||||
client.OnUpdateInventoryItem += UDPUpdateInventoryItemAsset;
|
client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
|
||||||
client.OnCopyInventoryItem += CopyInventoryItem;
|
client.OnCopyInventoryItem += CopyInventoryItem;
|
||||||
client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest;
|
client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest;
|
||||||
client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer;
|
client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer;
|
||||||
|
|
|
@ -108,7 +108,7 @@ namespace SimpleApp
|
||||||
public event FetchInventoryDescendents OnFetchInventoryDescendents;
|
public event FetchInventoryDescendents OnFetchInventoryDescendents;
|
||||||
public event FetchInventory OnFetchInventory;
|
public event FetchInventory OnFetchInventory;
|
||||||
public event RequestTaskInventory OnRequestTaskInventory;
|
public event RequestTaskInventory OnRequestTaskInventory;
|
||||||
public event UpdateInventoryItemTransaction OnUpdateInventoryItem;
|
public event UpdateInventoryItem OnUpdateInventoryItem;
|
||||||
public event CopyInventoryItem OnCopyInventoryItem;
|
public event CopyInventoryItem OnCopyInventoryItem;
|
||||||
public event UDPAssetUploadRequest OnAssetUploadRequest;
|
public event UDPAssetUploadRequest OnAssetUploadRequest;
|
||||||
public event XferReceive OnXferReceive;
|
public event XferReceive OnXferReceive;
|
||||||
|
@ -158,6 +158,11 @@ namespace SimpleApp
|
||||||
get { return LLUUID.Zero; }
|
get { return LLUUID.Zero; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public LLUUID SecureSessionId
|
||||||
|
{
|
||||||
|
get { return LLUUID.Zero; }
|
||||||
|
}
|
||||||
|
|
||||||
public virtual string FirstName
|
public virtual string FirstName
|
||||||
{
|
{
|
||||||
get { return "Annoying"; }
|
get { return "Annoying"; }
|
||||||
|
|
Loading…
Reference in New Issue