From 21dedb573be61a52cbbcc519f999f6046e20e070 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Thu, 6 Jan 2011 12:48:28 -0800 Subject: HG map tile fetch: handle cached images appropriately. --- .../Connectors/Hypergrid/GatekeeperServiceConnector.cs | 16 ++++++++++++---- OpenSim/Services/GridService/HypergridLinker.cs | 2 +- 2 files changed, 13 insertions(+), 5 deletions(-) (limited to 'OpenSim/Services') diff --git a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs index 1aa3282..8ab323a 100644 --- a/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs +++ b/OpenSim/Services/Connectors/Hypergrid/GatekeeperServiceConnector.cs @@ -158,10 +158,17 @@ namespace OpenSim.Services.Connectors.Hypergrid try { WebClient c = new WebClient(); - //m_log.Debug("JPEG: " + imageURL); string name = regionID.ToString(); filename = Path.Combine(storagePath, name + ".jpg"); - c.DownloadFile(imageURL, filename); + m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: Map image at {0}, cached at {1}", imageURL, filename); + if (!File.Exists(filename)) + { + m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: downloading..."); + c.DownloadFile(imageURL, filename); + } + else + m_log.DebugFormat("[GATEKEEPER SERVICE CONNECTOR]: using cached image"); + bitmap = new Bitmap(filename); //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); byte[] imageData = OpenJPEG.EncodeFromImage(bitmap, true); @@ -172,10 +179,11 @@ namespace OpenSim.Services.Connectors.Hypergrid ass.Data = imageData; - m_AssetService.Store(ass); + mapTile = ass.FullID; // finally - mapTile = ass.FullID; + m_AssetService.Store(ass); + } catch // LEGIT: Catching problems caused by OpenJPEG p/invoke { diff --git a/OpenSim/Services/GridService/HypergridLinker.cs b/OpenSim/Services/GridService/HypergridLinker.cs index c02c813..16fcc65 100644 --- a/OpenSim/Services/GridService/HypergridLinker.cs +++ b/OpenSim/Services/GridService/HypergridLinker.cs @@ -324,7 +324,7 @@ namespace OpenSim.Services.GridService regInfo.TerrainImage = m_GatekeeperConnector.GetMapImage(regionID, imageURL, m_MapTileDirectory); AddHyperlinkRegion(regInfo, handle); - m_log.Info("[HYPERGRID LINKER]: Successfully linked to region_uuid " + regInfo.RegionID); + m_log.InfoFormat("[HYPERGRID LINKER]: Successfully linked to region_uuid {0} with image {1}", regInfo.RegionID, regInfo.TerrainImage); return true; } -- cgit v1.1