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,
Utils.StringToBytes(sceneObjectXml),
sp.UUID);
m_scene.AssetService.Store(asset);
item.AssetID = asset.FullID;
item.Description = asset.Description;
item.Name = asset.Name;
item.AssetType = asset.Type;
item.InvType = (int)InventoryType.Object;
IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
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
// item in the viewer.

View File

@ -253,6 +253,20 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
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
///

View File

@ -292,7 +292,31 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess
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(
DeRezAction action, UUID folderID,
List<SceneObjectGroup> objectGroups, IClientAPI remoteClient, bool asAttachment)

View File

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