Fixed a problem with detaching attachments in situations where the user's asset server is not the same as the simulator's asset server. Unfortunately this still continues to be wasteful -- new assets are created every time an attachment is detached, but the process of storing the new asset goes through the InventoryAccess module, which does all sorts of checks regarding the users' inventory.

bullet-2.82
Diva Canto 2014-05-22 10:16:01 -07:00
parent ab1472e5b7
commit f7b2aa0f49
4 changed files with 44 additions and 9 deletions

View File

@ -774,15 +774,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
(sbyte)AssetType.Object, (sbyte)AssetType.Object,
Utils.StringToBytes(sceneObjectXml), Utils.StringToBytes(sceneObjectXml),
sp.UUID); sp.UUID);
m_scene.AssetService.Store(asset);
item.AssetID = asset.FullID; IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
item.Description = asset.Description;
item.Name = asset.Name;
item.AssetType = asset.Type;
item.InvType = (int)InventoryType.Object;
m_scene.InventoryService.UpdateItem(item); invAccess.UpdateInventoryItemAsset(sp.UUID, item, asset);
// If the name of the object has been changed whilst attached then we want to update the inventory // If the name of the object has been changed whilst attached then we want to update the inventory
// item in the viewer. // item in the viewer.

View File

@ -253,6 +253,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
return newAssetID; return newAssetID;
} }
///
/// UpdateInventoryItemAsset
///
public override bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset)
{
if (base.UpdateInventoryItemAsset(ownerID, item, asset))
{
UploadInventoryItem(ownerID, (AssetType)asset.Type, asset.FullID, asset.Name, 0);
return true;
}
return false;
}
/// ///
/// Used in DeleteToInventory /// Used in DeleteToInventory
/// ///

View File

@ -293,6 +293,30 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
return UUID.Zero; return UUID.Zero;
} }
public virtual bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset)
{
if (item != null && item.Owner == ownerID && asset != null)
{
item.AssetID = asset.FullID;
item.Description = asset.Description;
item.Name = asset.Name;
item.AssetType = asset.Type;
item.InvType = (int)InventoryType.Object;
m_Scene.AssetService.Store(asset);
m_Scene.InventoryService.UpdateItem(item);
return true;
}
else
{
m_log.ErrorFormat("[INVENTORY ACCESS MODULE]: Given invalid item for inventory update: {0}",
(item == null || asset == null? "null item or asset" : "wrong owner"));
return false;
}
}
public virtual List<InventoryItemBase> CopyToInventory( public virtual List<InventoryItemBase> CopyToInventory(
DeRezAction action, UUID folderID, DeRezAction action, UUID folderID,
List<SceneObjectGroup> objectGroups, IClientAPI remoteClient, bool asAttachment) List<SceneObjectGroup> objectGroups, IClientAPI remoteClient, bool asAttachment)

View File

@ -39,6 +39,8 @@ namespace OpenSim.Region.Framework.Interfaces
{ {
UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data); UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data);
bool UpdateInventoryItemAsset(UUID ownerID, InventoryItemBase item, AssetBase asset);
/// <summary> /// <summary>
/// Copy objects to a user's inventory. /// Copy objects to a user's inventory.
/// </summary> /// </summary>