diff --git a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs index 423f4b8276..cdb93f238d 100644 --- a/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/UserProfiles/UserProfileModule.cs @@ -1891,16 +1891,7 @@ namespace OpenSim.Region.CoreModules.Avatar.UserProfiles if(string.IsNullOrWhiteSpace(assetServerURI)) return; - string imageIDstr = imageID.ToString(); - - - if(m_assetCache != null && m_assetCache.Check(imageIDstr)) - return; - - if(Scene.AssetService.Get(imageIDstr) != null) - return; - - Scene.AssetService.Get(string.Format("{0}/{1}", assetServerURI, imageIDstr)); + Scene.AssetService.Get(imageID.ToString(), assetServerURI); } /// diff --git a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs index cdd32f0135..922831577b 100644 --- a/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs +++ b/OpenSim/Region/CoreModules/Framework/InventoryAccess/HGAssetMapper.cs @@ -98,10 +98,7 @@ namespace OpenSim.Region.CoreModules.Framework.InventoryAccess if (string.IsNullOrEmpty(url)) return null; - if (!url.EndsWith("/") && !url.EndsWith("=")) - url = url + "/"; - - asset = m_scene.AssetService.Get(url + assetIDstr); + asset = m_scene.AssetService.Get(assetIDstr, url); //if (asset != null) // m_log.DebugFormat("[HG ASSET MAPPER]: Fetched asset {0} of type {1} from {2} ", assetID, asset.Metadata.Type, url); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs index 07911ba809..3139205713 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/HGAssetBroker.cs @@ -153,6 +153,41 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset return asset; } + public AssetBase Get(string id, string ForeignAssetService) + { + // assumes id and ForeignAssetService are valid and resolved + AssetBase asset = null; + if (m_Cache != null) + { + m_Cache.Get(id, out asset); // negative cache is a fail on HG + } + + if (asset == null) + { + asset = GetFromLocal(id); + if (asset == null) + { + asset = GetFromForeign(id, ForeignAssetService); + if (asset != null) + { + if (m_AssetPerms.AllowedImport(asset.Type)) + base.Store(asset); + else + { + if (m_Cache != null) + m_Cache.CacheNegative(id); + return null; + } + } + else if (m_Cache != null) + m_Cache.CacheNegative(id); + } + else if (m_Cache != null) + m_Cache.Cache(asset); + } + return asset; + } + public override AssetMetadata GetMetadata(string id) { if (IsHG(id)) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs index 7000b1509b..a26c445f1e 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/LocalAssetServiceConnector.cs @@ -151,8 +151,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset if (asset == null) { asset = m_AssetService.Get(id); - if ((m_Cache != null) && (asset != null) && asset.ID != id) - m_Cache.Cache(asset); + if (m_Cache != null) + { + if(asset != null) + m_Cache.Cache(asset); + else + m_Cache.CacheNegative(id); + } //if (null == asset) // m_log.WarnFormat("[LOCAL ASSET SERVICES CONNECTOR]: Could not synchronously find asset with id {0}", id); @@ -243,7 +248,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset } } - return m_AssetService.Get(id, sender, delegate (string assetID, Object s, AssetBase a) + return m_AssetService.Get(id, sender, delegate (string assetID, object s, AssetBase a) { if ((a != null) && (m_Cache != null)) m_Cache.Cache(a); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RegionBaseAssetServicesConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RegionBaseAssetServicesConnector.cs index b7503fbbdb..b62bc7d668 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RegionBaseAssetServicesConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RegionBaseAssetServicesConnector.cs @@ -313,11 +313,9 @@ namespace OpenSim.Services.Connectors return null; } - if (asset == null || asset.Data == null || asset.Data.Length == 0) + if (asset == null) { - string uri = MapServer(id) + "/assets/" + id; - - asset = SynchronousRestObjectRequester.MakeRequest("GET", uri, 0, m_Auth); + asset = GetFromLocal(id); if (m_Cache != null) { if (asset != null) @@ -329,28 +327,21 @@ namespace OpenSim.Services.Connectors return asset; } - public AssetBase Get(string id, string ForeignAssetService) + public AssetBase GetFromLocal(string id) { - // assumes id and ForeignAssetService are valid and resolved - AssetBase asset = null; - if (m_Cache != null) - { - m_Cache.Get(id, out asset); // negative cache is a fail on HG - } + string local = MapServer(id) + "/assets/" + id; + return SynchronousRestObjectRequester.MakeRequest("GET", local, 0, m_Auth); + } - if (asset == null) - { - IServiceAuth auth = null; - if (ForeignAssetService.Equals(m_ServerURI)) - { - ForeignAssetService = MapServer(id) + "/assets/" + id; - auth = m_Auth; - } - else - ForeignAssetService = ForeignAssetService + "/assets/" + id; - asset = SynchronousRestObjectRequester.MakeRequest("GET", ForeignAssetService, 0, auth); - } - return asset; + public AssetBase GetFromForeign(string id, string ForeignAssetService) + { + if(string.IsNullOrEmpty(ForeignAssetService) || ForeignAssetService.Equals(m_ServerURI)) + return null; + if(ForeignAssetService.EndsWith("/")) + ForeignAssetService = ForeignAssetService + "assets/" + id; + else + ForeignAssetService = ForeignAssetService + "/assets/" + id; + return SynchronousRestObjectRequester.MakeRequest("GET", ForeignAssetService, 0, null); } public AssetBase GetForeign(string id) @@ -367,7 +358,7 @@ namespace OpenSim.Services.Connectors m_Cache.Get(uuidstr, out asset); // negative cache is a fail on HG } - if (asset == null || asset.Data == null || asset.Data.Length == 0) + if (asset == null) { IServiceAuth auth = null; if (type == 0) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RemoteAssetServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RemoteAssetServiceConnector.cs index 03499a7524..96127ca1ce 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RemoteAssetServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Asset/RemoteAssetServiceConnector.cs @@ -112,5 +112,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Asset else m_log.InfoFormat("[ASSET CONNECTOR]: Enabled remote assets without caching for region {0}", scene.RegionInfo.RegionName); } + + public AssetBase Get(string id, string ForeignAssetService) + { + return Get(id); // no hg + } } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index bfedd10ee6..a8c73960eb 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -122,9 +122,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } Object[] args = new Object[] { source }; - m_GridService = - ServerUtils.LoadPlugin(serviceDll, - args); + m_GridService = ServerUtils.LoadPlugin(serviceDll, args); if (m_GridService == null) {