From 7eb12f96ec91b5c2dec5468af5088dbaed12d4e8 Mon Sep 17 00:00:00 2001 From: Oren Hurvitz Date: Wed, 23 Apr 2014 08:44:00 +0300 Subject: Hypergrid: don't send Local assets to other grids This commit also contains other changes, but they're all just for clarity. The only actual behavior change is to avoid Posting local assets. --- .../Framework/InventoryAccess/HGAssetMapper.cs | 69 +++++++++++----------- 1 file changed, 34 insertions(+), 35 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs index cbf32ad..04615a9 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs @@ -118,45 +118,44 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess if (string.IsNullOrEmpty(url)) return false; - if (asset != null) - { - if (!url.EndsWith("/") && !url.EndsWith("=")) - url = url + "/"; - - bool success = true; - // See long comment in AssetCache.AddAsset - if (!asset.Temporary || asset.Local) - { - // We need to copy the asset into a new asset, because - // we need to set its ID to be URL+UUID, so that the - // HGAssetService dispatches it to the remote grid. - // It's not pretty, but the best that can be done while - // not having a global naming infrastructure - AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type, asset.Metadata.CreatorID); - Copy(asset, asset1); - asset1.ID = url + asset.ID; - - AdjustIdentifiers(asset1.Metadata); - if (asset1.Metadata.Type == (sbyte)AssetType.Object) - asset1.Data = AdjustIdentifiers(asset.Data); - else - asset1.Data = asset.Data; + if (!url.EndsWith("/") && !url.EndsWith("=")) + url = url + "/"; - string id = m_scene.AssetService.Store(asset1); - if (String.IsNullOrEmpty(id)) - { - m_log.DebugFormat("[HG ASSET MAPPER]: Failed to post asset {0} to asset server {1}: the server did not accept the asset", asset.ID, url); - success = false; - } - else - m_log.DebugFormat("[HG ASSET MAPPER]: Posted asset {0} to asset server {1}", asset1.ID, url); - } - return success; + if (asset == null) + { + m_log.Warn("[HG ASSET MAPPER]: Tried to post asset to remote server, but asset not in local cache."); + return false; } + + // See long comment in AssetCache.AddAsset + if (asset.Temporary || asset.Local) + return true; + + // We need to copy the asset into a new asset, because + // we need to set its ID to be URL+UUID, so that the + // HGAssetService dispatches it to the remote grid. + // It's not pretty, but the best that can be done while + // not having a global naming infrastructure + AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type, asset.Metadata.CreatorID); + Copy(asset, asset1); + asset1.ID = url + asset.ID; + + AdjustIdentifiers(asset1.Metadata); + if (asset1.Metadata.Type == (sbyte)AssetType.Object) + asset1.Data = AdjustIdentifiers(asset.Data); else - m_log.Warn("[HG ASSET MAPPER]: Tried to post asset to remote server, but asset not in local cache."); + asset1.Data = asset.Data; - return false; + string id = m_scene.AssetService.Store(asset1); + if (String.IsNullOrEmpty(id)) + { + m_log.DebugFormat("[HG ASSET MAPPER]: Asset server {0} did not accept {1}", url, asset.ID); + return false; + } + else { + m_log.DebugFormat("[HG ASSET MAPPER]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url); + return true; + } } private void Copy(AssetBase from, AssetBase to) -- cgit v1.1