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
Sean Dague 2007-12-03 20:06:01 +00:00
parent 5061808afc
commit 8f58a9a107
5 changed files with 120 additions and 51 deletions

View File

@ -310,8 +310,9 @@ namespace OpenSim.Framework
public delegate void RequestTaskInventory(IClientAPI remoteClient, uint localID);
public delegate void UpdateInventoryItemTransaction(
IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID, LLUUID itemID);
public delegate void UpdateInventoryItem(
IClientAPI remoteClient, LLUUID transactionID, LLUUID itemID, string name, string description,
uint nextOwnerMask);
public delegate void CopyInventoryItem(
IClientAPI remoteClient, uint callbackID, LLUUID oldAgentID, LLUUID oldItemID, LLUUID newFolderID, string newName);
@ -392,7 +393,7 @@ namespace OpenSim.Framework
event FetchInventoryDescendents OnFetchInventoryDescendents;
event FetchInventory OnFetchInventory;
event RequestTaskInventory OnRequestTaskInventory;
event UpdateInventoryItemTransaction OnUpdateInventoryItem;
event UpdateInventoryItem OnUpdateInventoryItem;
event CopyInventoryItem OnCopyInventoryItem;
event UDPAssetUploadRequest OnAssetUploadRequest;
event XferReceive OnXferReceive;
@ -417,6 +418,8 @@ namespace OpenSim.Framework
LLUUID AgentId { get; }
LLUUID SessionId { get; }
LLUUID SecureSessionId { get; }
string FirstName { get; }
@ -481,7 +484,7 @@ namespace OpenSim.Framework
/// <summary>
/// Tell the client that we have created the item it requested.
/// </summary>
/// <param name="Item"></param>
/// <param name="Item"></param>
void SendInventoryItemCreateUpdate(InventoryItemBase Item);
void SendRemoveInventoryItem(LLUUID itemID);

View File

@ -59,7 +59,14 @@ namespace OpenSim.Region.ClientStack
//local handlers for this instance
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 lastName;
private UseCircuitCodePacket cirpack;
@ -540,7 +547,7 @@ namespace OpenSim.Region.ClientStack
if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero)
{
SecureSessionID = sessionInfo.LoginInfo.SecureSession;
m_secureSessionId = sessionInfo.LoginInfo.SecureSession;
}
InitNewClient();
@ -615,7 +622,7 @@ namespace OpenSim.Region.ClientStack
public event FetchInventoryDescendents OnFetchInventoryDescendents;
public event FetchInventory OnFetchInventory;
public event RequestTaskInventory OnRequestTaskInventory;
public event UpdateInventoryItemTransaction OnUpdateInventoryItem;
public event UpdateInventoryItem OnUpdateInventoryItem;
public event CopyInventoryItem OnCopyInventoryItem;
public event UDPAssetUploadRequest OnAssetUploadRequest;
public event XferReceive OnXferReceive;
@ -888,7 +895,7 @@ namespace OpenSim.Region.ClientStack
AgentCircuitData agentData = new AgentCircuitData();
agentData.AgentID = AgentId;
agentData.SessionID = m_sessionId;
agentData.SecureSessionID = SecureSessionID;
agentData.SecureSessionID = SecureSessionId;
agentData.circuitcode = m_circuitCode;
agentData.child = false;
agentData.firstname = firstName;
@ -2953,10 +2960,10 @@ namespace OpenSim.Region.ClientStack
case PacketType.AssetUploadRequest:
AssetUploadRequestPacket request = (AssetUploadRequestPacket) Pack;
// 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)
{
OnAssetUploadRequest(this, request.AssetBlock.TransactionID.Combine(SecureSessionID),
OnAssetUploadRequest(this, request.AssetBlock.TransactionID.Combine(SecureSessionId),
request.AssetBlock.TransactionID, request.AssetBlock.Type,
request.AssetBlock.AssetData, request.AssetBlock.StoreLocal);
}
@ -3033,12 +3040,11 @@ namespace OpenSim.Region.ClientStack
{
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].TransactionID.Combine(SecureSessionID),
update.InventoryData[i].ItemID);
}
OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID,
update.InventoryData[i].ItemID,
Util.FieldToString(update.InventoryData[i].Name),
Util.FieldToString(update.InventoryData[i].Description),
update.InventoryData[i].NextOwnerMask);
}
}
//Console.WriteLine(Pack.ToString());
@ -3046,7 +3052,7 @@ namespace OpenSim.Region.ClientStack
{
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)
{
// Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache");

View File

@ -106,52 +106,107 @@ namespace OpenSim.Region.Environment.Scenes
return LLUUID.Zero;
}
public void UDPUpdateInventoryItemAsset(IClientAPI remoteClient, LLUUID transactionID, LLUUID assetID,
LLUUID itemID)
{
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
/// <summary>
/// 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);
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);
if (item != null)
AssetBase asset = 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 =
CommsManager.TransactionsManager.GetUserTransActions(remoteClient.AgentId);
asset = AssetCache.GetAsset(item.assetID);
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)
{
AssetBase asset = null;
bool addToCache = false;
LLUUID assetID = transactionID.Combine(remoteClient.SecureSessionId);
asset = AssetCache.GetAsset(assetID);
if (asset == null)
{
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.InvType = (sbyte) item.invType;
asset.Type = (sbyte) item.assetType;
item.assetID = asset.FullID;
if (addToCache)
{
AssetCache.AddAsset(asset);
}
userInfo.UpdateItem(remoteClient.AgentId, item);
}
asset.Name = item.inventoryName;
asset.Description = item.inventoryDescription;
asset.InvType = (sbyte) item.invType;
asset.Type = (sbyte) item.assetType;
item.assetID = asset.FullID;
addAsset = true;
}
}
}
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.");
}
}
@ -507,4 +562,4 @@ namespace OpenSim.Region.Environment.Scenes
rootPart.ScheduleFullUpdate();
}
}
}
}

View File

@ -989,7 +989,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnFetchInventoryDescendents += CommsManager.UserProfileCacheService.HandleFecthInventoryDescendents;
client.OnRequestTaskInventory += RequestTaskInventory;
client.OnFetchInventory += CommsManager.UserProfileCacheService.HandleFetchInventory;
client.OnUpdateInventoryItem += UDPUpdateInventoryItemAsset;
client.OnUpdateInventoryItem += UpdateInventoryItemAsset;
client.OnCopyInventoryItem += CopyInventoryItem;
client.OnAssetUploadRequest += CommsManager.TransactionsManager.HandleUDPUploadRequest;
client.OnXferReceive += CommsManager.TransactionsManager.HandleXfer;

View File

@ -108,7 +108,7 @@ namespace SimpleApp
public event FetchInventoryDescendents OnFetchInventoryDescendents;
public event FetchInventory OnFetchInventory;
public event RequestTaskInventory OnRequestTaskInventory;
public event UpdateInventoryItemTransaction OnUpdateInventoryItem;
public event UpdateInventoryItem OnUpdateInventoryItem;
public event CopyInventoryItem OnCopyInventoryItem;
public event UDPAssetUploadRequest OnAssetUploadRequest;
public event XferReceive OnXferReceive;
@ -157,6 +157,11 @@ namespace SimpleApp
{
get { return LLUUID.Zero; }
}
public LLUUID SecureSessionId
{
get { return LLUUID.Zero; }
}
public virtual string FirstName
{