From 717fd3b5b91f54113ef554799f124275d5489ea1 Mon Sep 17 00:00:00 2001 From: Dr Scofield Date: Wed, 3 Jun 2009 12:48:04 +0000 Subject: From: Chris Yeoh This patch adds oar file date and time (UTC) meta data to an oar file when it is created. It also adds a unique ID, though this id does not in anyway identify the machine that the oar file was created on. When an oar file with this meta data is loaded this extra information is saved with the region settings and available via LSL through: - osLoadedCreationDate() - osLoadedCreationTime() - osLoadedCreationID() If there is no meta data these fields will be blank. Subsequent oar file loads will erase the information for the previous oar file load. Persistence has only been implemented for MySQL, the other backends need updating. Overall this allows us to much more easily identify the specific version of software that clients are using. Its very straightforward to edit the oar file to change the ID string to be something more human friendly. Included in the patch is a new file OpenSim/Data/MySQL/Resources/030_RegionStore.sql required for the MySQL DB migration. btw I had a chat with justincc about this a few weeks ago since he wrote the oar file import/export and he sounded happy to accept something that included date/time information but didn't want anything that would silently leak private information like machine names. --- .../World/Archiver/ArchiveReadRequest.cs | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs') diff --git a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs index 74904e2..e26c145 100644 --- a/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs +++ b/OpenSim/Region/CoreModules/World/Archiver/ArchiveReadRequest.cs @@ -32,6 +32,7 @@ using System.IO.Compression; using System.Net; using System.Reflection; using System.Text; +using System.Xml; using log4net; using OpenMetaverse; using OpenSim.Framework; @@ -134,6 +135,8 @@ namespace OpenSim.Region.CoreModules.World.Archiver else if (!m_merge && filePath.StartsWith(ArchiveConstants.SETTINGS_PATH)) { LoadRegionSettings(filePath, data); + } else if (filePath == ArchiveConstants.CONTROL_FILE_PATH) { + LoadArchiveMetadata(filePath, data); } } @@ -478,5 +481,60 @@ namespace OpenSim.Region.CoreModules.World.Archiver // return new BufferedStream(file, (int) response.ContentLength); return new BufferedStream(file, 1000000); } + + /// + /// Load oar file metadata + /// + /// + /// + /// + /// true if terrain was resolved successfully, false otherwise. + /// + private bool LoadArchiveMetadata(string terrainPath, byte[] data) + { + //Create the XmlNamespaceManager. + NameTable nt = new NameTable(); + XmlNamespaceManager nsmgr = new XmlNamespaceManager(nt); + + // Create the XmlParserContext. + XmlParserContext context = new XmlParserContext(null, nsmgr, null, XmlSpace.None); + + XmlTextReader xtr = new XmlTextReader(m_asciiEncoding.GetString(data), + XmlNodeType.Document, context); + + + RegionSettings currentRegionSettings = m_scene.RegionInfo.RegionSettings; + + // Loaded metadata will empty if no information exists in the archive + currentRegionSettings.LoadedCreationDate = ""; + currentRegionSettings.LoadedCreationTime = ""; + currentRegionSettings.LoadedCreationID = ""; + + while (xtr.Read()) + { + if (xtr.NodeType == XmlNodeType.Element) + { + if (xtr.Name.ToString()=="date") + { + currentRegionSettings.LoadedCreationDate = xtr.ReadElementContentAsString(); + } + else if (xtr.Name.ToString()=="time") + { + currentRegionSettings.LoadedCreationTime = xtr.ReadElementContentAsString(); + } + else if (xtr.Name.ToString()=="id") + { + currentRegionSettings.LoadedCreationID = xtr.ReadElementContentAsString(); + } + } + + } + currentRegionSettings.Save(); + + return true; + } + + + } } -- cgit v1.1