This should make HG asset transfers work much better. It now uses HGUuidGatherer, which is a subclass of UuidGatherer. Hence, on-line HG asset transfers use exactly the same UUID collection code as save oar/xml. If it doesn't work, it's Justin's fault :D

0.6.6-post-fixes
diva 2009-05-23 17:51:13 +00:00
parent c287c4c57b
commit fb6d314d4d
6 changed files with 77 additions and 119 deletions

View File

@ -169,7 +169,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectors.Asset
public AssetBase Get(string id)
{
m_log.DebugFormat("[HG ASSET CONNECTOR]: Get {0}", id);
//m_log.DebugFormat("[HG ASSET CONNECTOR]: Get {0}", id);
AssetBase asset = null;
if (m_Cache != null)

View File

@ -97,7 +97,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
return false;
}
private AssetBase FetchAsset(string url, UUID assetID, bool isTexture)
public AssetBase FetchAsset(string url, UUID assetID)
{
AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString());
@ -109,7 +109,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
return null;
}
private bool PostAsset(string url, AssetBase asset)
public bool PostAsset(string url, AssetBase asset)
{
if (asset != null)
{
@ -129,7 +129,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
}
catch
{
m_log.Warn("[HGScene]: This won't work until Melanie kills a few more dragons");
m_log.Warn("[HGScene]: Oops.");
}
m_scene.AssetService.Store(asset1);
@ -155,86 +155,6 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
}
private void _guardedAdd(Dictionary<UUID, bool> lst, UUID obj, bool val)
{
if (!lst.ContainsKey(obj))
lst.Add(obj, val);
}
private void SniffTextureUUIDs(Dictionary<UUID, bool> uuids, SceneObjectGroup sog)
{
try
{
_guardedAdd(uuids, sog.RootPart.Shape.Textures.DefaultTexture.TextureID, true);
}
catch (Exception) { }
foreach (Primitive.TextureEntryFace tface in sog.RootPart.Shape.Textures.FaceTextures)
{
try
{
_guardedAdd(uuids, tface.TextureID, true);
}
catch (Exception) { }
}
foreach (SceneObjectPart sop in sog.Children.Values)
{
try
{
_guardedAdd(uuids, sop.Shape.Textures.DefaultTexture.TextureID, true);
}
catch (Exception) { }
foreach (Primitive.TextureEntryFace tface in sop.Shape.Textures.FaceTextures)
{
try
{
_guardedAdd(uuids, tface.TextureID, true);
}
catch (Exception) { }
}
}
}
private void SniffTaskInventoryUUIDs(Dictionary<UUID, bool> uuids, SceneObjectGroup sog)
{
TaskInventoryDictionary tinv = sog.RootPart.TaskInventory;
lock (tinv)
{
foreach (TaskInventoryItem titem in tinv.Values)
{
uuids.Add(titem.AssetID, (InventoryType)titem.Type == InventoryType.Texture);
}
}
}
private Dictionary<UUID, bool> SniffUUIDs(AssetBase asset)
{
Dictionary<UUID, bool> uuids = new Dictionary<UUID, bool>();
if ((asset != null) && ((AssetType)asset.Type == AssetType.Object))
{
string ass_str = Utils.BytesToString(asset.Data);
SceneObjectGroup sog = SceneObjectSerializer.FromOriginalXmlFormat(ass_str);
SniffTextureUUIDs(uuids, sog);
// We need to sniff further...
SniffTaskInventoryUUIDs(uuids, sog);
}
return uuids;
}
private Dictionary<UUID, bool> SniffUUIDs(UUID assetID)
{
//Dictionary<UUID, bool> uuids = new Dictionary<UUID, bool>();
AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
return SniffUUIDs(asset);
}
private void Dump(Dictionary<UUID, bool> lst)
{
m_log.Debug("XXX -------- UUID DUMP ------- XXX");
@ -259,16 +179,18 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
if (userAssetURL != null)
{
m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL);
AssetBase asset = FetchAsset(userAssetURL, assetID, false);
AssetBase asset = FetchAsset(userAssetURL, assetID);
if (asset != null)
{
m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL);
// OK, now fetch the inside.
Dictionary<UUID, bool> ids = SniffUUIDs(asset);
Dump(ids);
foreach (KeyValuePair<UUID, bool> kvp in ids)
FetchAsset(userAssetURL, kvp.Key, kvp.Value);
Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
foreach (UUID uuid in ids.Keys)
FetchAsset(userAssetURL, uuid);
}
else
m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);
@ -315,21 +237,23 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
if (userAssetURL != null)
{
m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL);
AssetBase ass1 = m_scene.AssetService.Get(assetID.ToString());
if (ass1 != null)
AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
if (asset != null)
{
bool success = PostAsset(userAssetURL, ass1);
// Now the inside
Dictionary<UUID, bool> ids = SniffUUIDs(assetID);
Dump(ids);
foreach (KeyValuePair<UUID, bool> kvp in ids)
Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty);
uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
foreach (UUID uuid in ids.Keys)
{
ass1 = m_scene.AssetService.Get(kvp.Key.ToString());
PostAsset(userAssetURL, ass1);
asset = m_scene.AssetService.Get(uuid.ToString());
if (asset != null)
m_log.DebugFormat("[HGScene]: Posting {0} {1}", asset.Type.ToString(), asset.Name);
else
m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid);
PostAsset(userAssetURL, asset);
}
if (success)
if (ids.Count > 0) // maybe it succeeded...
m_log.DebugFormat("[HGScene]: Successfully posted item {0} to remote asset server {1}", assetID, userAssetURL);
else
m_log.WarnFormat("[HGScene]: Could not post asset {0} to remote asset server {1}", assetID, userAssetURL);

View File

@ -113,24 +113,28 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
{
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
if (userInfo.RootFolder != null)
{
InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
//m_log.DebugFormat("[HGScene] RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID);
if (item == null)
{ // Fetch the item
item = new InventoryItemBase();
item.Owner = remoteClient.AgentId;
item.ID = itemID;
item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo);
}
if (item != null)
if (fromTaskID.Equals(UUID.Zero))
{
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo != null)
{
if (userInfo.RootFolder != null)
{
m_assMapper.Get(item.AssetID, remoteClient.AgentId);
InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
if (item == null)
{ // Fetch the item
item = new InventoryItemBase();
item.Owner = remoteClient.AgentId;
item.ID = itemID;
item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo);
}
if (item != null)
{
m_assMapper.Get(item.AssetID, remoteClient.AgentId);
}
}
}
}

View File

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using OpenSim.Framework;
using OpenSim.Services.Interfaces;
using OpenMetaverse;
namespace OpenSim.Region.Framework.Scenes.Hypergrid
{
public class HGUuidGatherer : UuidGatherer
{
protected string m_assetServerURL;
protected HGAssetMapper m_assetMapper;
public HGUuidGatherer(HGAssetMapper assMap, IAssetService assetCache, string assetServerURL) : base(assetCache)
{
m_assetMapper = assMap;
m_assetServerURL = assetServerURL;
}
protected override AssetBase GetAsset(UUID uuid)
{
if (string.Empty == m_assetServerURL)
return m_assetCache.Get(uuid.ToString());
else
return m_assetMapper.FetchAsset(m_assetServerURL, uuid);
}
}
}

View File

@ -187,7 +187,7 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
/// <param name="uuid"></param>
/// <returns></returns>
protected AssetBase GetAsset(UUID uuid)
protected virtual AssetBase GetAsset(UUID uuid)
{
m_waitingForObjectAsset = true;
m_assetCache.Get(uuid.ToString(), this, AssetReceived);

View File

@ -66,7 +66,7 @@ namespace OpenSim.Services.AssetService
public AssetBase Get(string id)
{
m_log.DebugFormat("[ASSET SERVICE]: Get asset {0}", id);
//m_log.DebugFormat("[ASSET SERVICE]: Get asset {0}", id);
UUID assetID;
if (!UUID.TryParse(id, out assetID))
@ -99,7 +99,7 @@ namespace OpenSim.Services.AssetService
public bool Get(string id, Object sender, AssetRetrieved handler)
{
//m_log.DebugFormat("[AssetService]: Got request for {0}", id);
//m_log.DebugFormat("[AssetService]: Get asset async {0}", id);
UUID assetID;
@ -117,6 +117,7 @@ namespace OpenSim.Services.AssetService
public string Store(AssetBase asset)
{
//m_log.DebugFormat("[ASSET SERVICE]: Store asset {0} {1}", asset.Name, asset.ID);
m_Database.CreateAsset(asset);
return asset.ID;