aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/DataSnapshot
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/DataSnapshot/ObjectSnapshot.cs15
-rw-r--r--OpenSim/Region/DataSnapshot/SnapshotStore.cs48
2 files changed, 48 insertions, 15 deletions
diff --git a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
index c489972..3c39f9e 100644
--- a/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
+++ b/OpenSim/Region/DataSnapshot/ObjectSnapshot.cs
@@ -142,9 +142,18 @@ namespace OpenSim.Region.DataSnapshot.Providers
142 node.InnerText = m_scene.RegionInfo.RegionSettings.RegionUUID.ToString(); 142 node.InnerText = m_scene.RegionInfo.RegionSettings.RegionUUID.ToString();
143 xmlobject.AppendChild(node); 143 xmlobject.AppendChild(node);
144 144
145 node = nodeFactory.CreateNode(XmlNodeType.Element, "parceluuid", ""); 145 if (land != null && land.LandData != null)
146 node.InnerText = land.LandData.GlobalID.ToString(); 146 {
147 xmlobject.AppendChild(node); 147 node = nodeFactory.CreateNode(XmlNodeType.Element, "parceluuid", "");
148 node.InnerText = land.LandData.GlobalID.ToString();
149 xmlobject.AppendChild(node);
150 }
151 else
152 {
153 // Something is wrong with this object. Let's not list it.
154 m_log.WarnFormat("[DATASNAPSHOT]: Bad data for object {0} ({1}) in region {2}", obj.Name, obj.UUID, m_scene.RegionInfo.RegionName);
155 continue;
156 }
148 157
149 node = nodeFactory.CreateNode(XmlNodeType.Element, "location", ""); 158 node = nodeFactory.CreateNode(XmlNodeType.Element, "location", "");
150 Vector3 loc = obj.AbsolutePosition; 159 Vector3 loc = obj.AbsolutePosition;
diff --git a/OpenSim/Region/DataSnapshot/SnapshotStore.cs b/OpenSim/Region/DataSnapshot/SnapshotStore.cs
index 70cb205..aa3d2ff 100644
--- a/OpenSim/Region/DataSnapshot/SnapshotStore.cs
+++ b/OpenSim/Region/DataSnapshot/SnapshotStore.cs
@@ -30,6 +30,7 @@ using System.Collections.Generic;
30using System.IO; 30using System.IO;
31using System.Reflection; 31using System.Reflection;
32using System.Text; 32using System.Text;
33using System.Text.RegularExpressions;
33using System.Xml; 34using System.Xml;
34using log4net; 35using log4net;
35using OpenSim.Region.DataSnapshot.Interfaces; 36using OpenSim.Region.DataSnapshot.Interfaces;
@@ -98,13 +99,21 @@ namespace OpenSim.Region.DataSnapshot
98 { 99 {
99 String path = DataFileNameFragment(provider.GetParentScene, provider.Name); 100 String path = DataFileNameFragment(provider.GetParentScene, provider.Name);
100 101
101 using (XmlTextWriter snapXWriter = new XmlTextWriter(path, Encoding.Default)) 102 try
102 { 103 {
103 snapXWriter.Formatting = Formatting.Indented; 104 using (XmlTextWriter snapXWriter = new XmlTextWriter(path, Encoding.Default))
104 snapXWriter.WriteStartDocument(); 105 {
105 data.WriteTo(snapXWriter); 106 snapXWriter.Formatting = Formatting.Indented;
106 snapXWriter.WriteEndDocument(); 107 snapXWriter.WriteStartDocument();
108 data.WriteTo(snapXWriter);
109 snapXWriter.WriteEndDocument();
110 }
111 }
112 catch (Exception e)
113 {
114 m_log.WarnFormat("[DATASNAPSHOT]: Exception on writing to file {0}: {1}", path, e.Message);
107 } 115 }
116
108 } 117 }
109 118
110 //mark provider as not stale, parent scene as stale 119 //mark provider as not stale, parent scene as stale
@@ -185,12 +194,19 @@ namespace OpenSim.Region.DataSnapshot
185 //save snapshot 194 //save snapshot
186 String path = DataFileNameScene(scene); 195 String path = DataFileNameScene(scene);
187 196
188 using (XmlTextWriter snapXWriter = new XmlTextWriter(path, Encoding.Default)) 197 try
198 {
199 using (XmlTextWriter snapXWriter = new XmlTextWriter(path, Encoding.Default))
200 {
201 snapXWriter.Formatting = Formatting.Indented;
202 snapXWriter.WriteStartDocument();
203 regionElement.WriteTo(snapXWriter);
204 snapXWriter.WriteEndDocument();
205 }
206 }
207 catch (Exception e)
189 { 208 {
190 snapXWriter.Formatting = Formatting.Indented; 209 m_log.WarnFormat("[DATASNAPSHOT]: Exception on writing to file {0}: {1}", path, e.Message);
191 snapXWriter.WriteStartDocument();
192 regionElement.WriteTo(snapXWriter);
193 snapXWriter.WriteEndDocument();
194 } 210 }
195 211
196 m_scenes[scene] = false; 212 m_scenes[scene] = false;
@@ -206,15 +222,23 @@ namespace OpenSim.Region.DataSnapshot
206 #region Helpers 222 #region Helpers
207 private string DataFileNameFragment(Scene scene, String fragmentName) 223 private string DataFileNameFragment(Scene scene, String fragmentName)
208 { 224 {
209 return Path.Combine(m_directory, Path.ChangeExtension(scene.RegionInfo.RegionName + "_" + fragmentName, "xml")); 225 return Path.Combine(m_directory, Path.ChangeExtension(Sanitize(scene.RegionInfo.RegionName + "_" + fragmentName), "xml"));
210 } 226 }
211 227
212 private string DataFileNameScene(Scene scene) 228 private string DataFileNameScene(Scene scene)
213 { 229 {
214 return Path.Combine(m_directory, Path.ChangeExtension(scene.RegionInfo.RegionName, "xml")); 230 return Path.Combine(m_directory, Path.ChangeExtension(Sanitize(scene.RegionInfo.RegionName), "xml"));
215 //return (m_snapsDir + Path.DirectorySeparatorChar + scene.RegionInfo.RegionName + ".xml"); 231 //return (m_snapsDir + Path.DirectorySeparatorChar + scene.RegionInfo.RegionName + ".xml");
216 } 232 }
217 233
234 private static string Sanitize(string name)
235 {
236 string invalidChars = Regex.Escape(new string(Path.GetInvalidFileNameChars()));
237 string invalidReStr = string.Format(@"[{0}]", invalidChars);
238 string newname = Regex.Replace(name, invalidReStr, "_");
239 return newname.Replace('.', '_');
240 }
241
218 private XmlNode MakeRegionNode(Scene scene, XmlDocument basedoc) 242 private XmlNode MakeRegionNode(Scene scene, XmlDocument basedoc)
219 { 243 {
220 XmlNode docElement = basedoc.CreateNode(XmlNodeType.Element, "region", ""); 244 XmlNode docElement = basedoc.CreateNode(XmlNodeType.Element, "region", "");