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) 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; AssetBase asset = null;
if (m_Cache != null) if (m_Cache != null)

View File

@ -97,7 +97,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
return false; 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()); AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString());
@ -109,7 +109,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
return null; return null;
} }
private bool PostAsset(string url, AssetBase asset) public bool PostAsset(string url, AssetBase asset)
{ {
if (asset != null) if (asset != null)
{ {
@ -129,7 +129,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
} }
catch 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); 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) private void Dump(Dictionary<UUID, bool> lst)
{ {
m_log.Debug("XXX -------- UUID DUMP ------- XXX"); m_log.Debug("XXX -------- UUID DUMP ------- XXX");
@ -259,16 +179,18 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
if (userAssetURL != null) if (userAssetURL != null)
{ {
m_log.Debug("[HGScene]: Fetching object " + assetID + " to asset server " + userAssetURL); 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) if (asset != null)
{ {
m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL); m_log.Debug("[HGScene]: Successfully fetched item from remote asset server " + userAssetURL);
// OK, now fetch the inside. // OK, now fetch the inside.
Dictionary<UUID, bool> ids = SniffUUIDs(asset); Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
Dump(ids); HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
foreach (KeyValuePair<UUID, bool> kvp in ids) uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
FetchAsset(userAssetURL, kvp.Key, kvp.Value); foreach (UUID uuid in ids.Keys)
FetchAsset(userAssetURL, uuid);
} }
else else
m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL); 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) if (userAssetURL != null)
{ {
m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL); m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL);
AssetBase ass1 = m_scene.AssetService.Get(assetID.ToString()); AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
if (ass1 != null) if (asset != null)
{ {
bool success = PostAsset(userAssetURL, ass1); Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty);
// Now the inside uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
Dictionary<UUID, bool> ids = SniffUUIDs(assetID); foreach (UUID uuid in ids.Keys)
Dump(ids);
foreach (KeyValuePair<UUID, bool> kvp in ids)
{ {
ass1 = m_scene.AssetService.Get(kvp.Key.ToString()); asset = m_scene.AssetService.Get(uuid.ToString());
PostAsset(userAssetURL, ass1); 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); m_log.DebugFormat("[HGScene]: Successfully posted item {0} to remote asset server {1}", assetID, userAssetURL);
else else
m_log.WarnFormat("[HGScene]: Could not post asset {0} to remote asset server {1}", assetID, userAssetURL); m_log.WarnFormat("[HGScene]: Could not post asset {0} to remote asset server {1}", assetID, userAssetURL);

View File

@ -112,6 +112,10 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
public override SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, public override SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
{
//m_log.DebugFormat("[HGScene] RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID);
if (fromTaskID.Equals(UUID.Zero))
{ {
CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId);
if (userInfo != null) if (userInfo != null)
@ -119,7 +123,6 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
if (userInfo.RootFolder != null) if (userInfo.RootFolder != null)
{ {
InventoryItemBase item = userInfo.RootFolder.FindItem(itemID); InventoryItemBase item = userInfo.RootFolder.FindItem(itemID);
if (item == null) if (item == null)
{ // Fetch the item { // Fetch the item
item = new InventoryItemBase(); item = new InventoryItemBase();
@ -134,6 +137,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
} }
} }
} }
}
// OK, we're done fetching. Pass it up to the default RezObject // OK, we're done fetching. Pass it up to the default RezObject
return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,

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> /// </summary>
/// <param name="uuid"></param> /// <param name="uuid"></param>
/// <returns></returns> /// <returns></returns>
protected AssetBase GetAsset(UUID uuid) protected virtual AssetBase GetAsset(UUID uuid)
{ {
m_waitingForObjectAsset = true; m_waitingForObjectAsset = true;
m_assetCache.Get(uuid.ToString(), this, AssetReceived); m_assetCache.Get(uuid.ToString(), this, AssetReceived);

View File

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