diff options
author | Jeff Ames | 2007-11-17 05:53:12 +0000 |
---|---|---|
committer | Jeff Ames | 2007-11-17 05:53:12 +0000 |
commit | 946db5461c8262d3b957e42ed7a90feb447c618b (patch) | |
tree | 7ba5a76429f19881d684a9c317210f39e4cc70b1 /OpenSim/Framework/Communications/Cache | |
parent | fixed svn:ignore on POSPlugin (diff) | |
download | opensim-SC-946db5461c8262d3b957e42ed7a90feb447c618b.zip opensim-SC-946db5461c8262d3b957e42ed7a90feb447c618b.tar.gz opensim-SC-946db5461c8262d3b957e42ed7a90feb447c618b.tar.bz2 opensim-SC-946db5461c8262d3b957e42ed7a90feb447c618b.tar.xz |
catch exceptions when loading malformed xml files
Diffstat (limited to 'OpenSim/Framework/Communications/Cache')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetServerBase.cs | 38 | ||||
-rw-r--r-- | OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | 13 |
2 files changed, 34 insertions, 17 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs index 7692057..1a20cee 100644 --- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs +++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs | |||
@@ -2,6 +2,7 @@ using System; | |||
2 | using System.Collections.Generic; | 2 | using System.Collections.Generic; |
3 | using System.IO; | 3 | using System.IO; |
4 | using System.Threading; | 4 | using System.Threading; |
5 | using System.Xml; | ||
5 | using libsecondlife; | 6 | using libsecondlife; |
6 | using Nini.Config; | 7 | using Nini.Config; |
7 | using OpenSim.Framework.Console; | 8 | using OpenSim.Framework.Console; |
@@ -148,22 +149,29 @@ namespace OpenSim.Framework.Communications.Cache | |||
148 | string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); | 149 | string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); |
149 | if (File.Exists(filePath)) | 150 | if (File.Exists(filePath)) |
150 | { | 151 | { |
151 | XmlConfigSource source = new XmlConfigSource(filePath); | 152 | try |
152 | 153 | { | |
153 | for (int i = 0; i < source.Configs.Count; i++) | 154 | XmlConfigSource source = new XmlConfigSource(filePath); |
155 | |||
156 | for (int i = 0; i < source.Configs.Count; i++) | ||
157 | { | ||
158 | // System.Console.WriteLine("loading asset into database"); | ||
159 | string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); | ||
160 | string name = source.Configs[i].GetString("name", ""); | ||
161 | sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); | ||
162 | sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0); | ||
163 | string fileName = source.Configs[i].GetString("fileName", ""); | ||
164 | |||
165 | AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); | ||
166 | |||
167 | newAsset.Type = type; | ||
168 | newAsset.InvType = invType; | ||
169 | assets.Add(newAsset); | ||
170 | } | ||
171 | } | ||
172 | catch (XmlException e) | ||
154 | { | 173 | { |
155 | // System.Console.WriteLine("loading asset into database"); | 174 | MainLog.Instance.Error("ASSETS", "Error loading " + filePath + ": " + e.ToString()); |
156 | string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); | ||
157 | string name = source.Configs[i].GetString("name", ""); | ||
158 | sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); | ||
159 | sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0); | ||
160 | string fileName = source.Configs[i].GetString("fileName", ""); | ||
161 | |||
162 | AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); | ||
163 | |||
164 | newAsset.Type = type; | ||
165 | newAsset.InvType = invType; | ||
166 | assets.Add(newAsset); | ||
167 | } | 175 | } |
168 | } | 176 | } |
169 | assets.ForEach(action); | 177 | assets.ForEach(action); |
diff --git a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs index 765c42e..05caa84 100644 --- a/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs +++ b/OpenSim/Framework/Communications/Cache/LibraryRootFolder.cs | |||
@@ -27,8 +27,10 @@ | |||
27 | */ | 27 | */ |
28 | 28 | ||
29 | using System.IO; | 29 | using System.IO; |
30 | using System.Xml; | ||
30 | using libsecondlife; | 31 | using libsecondlife; |
31 | using Nini.Config; | 32 | using Nini.Config; |
33 | using OpenSim.Framework.Console; | ||
32 | 34 | ||
33 | namespace OpenSim.Framework.Communications.Cache | 35 | namespace OpenSim.Framework.Communications.Cache |
34 | { | 36 | { |
@@ -65,8 +67,15 @@ namespace OpenSim.Framework.Communications.Cache | |||
65 | string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml"); | 67 | string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml"); |
66 | if (File.Exists(filePath)) | 68 | if (File.Exists(filePath)) |
67 | { | 69 | { |
68 | XmlConfigSource source = new XmlConfigSource(filePath); | 70 | try |
69 | ReadItemsFromFile(source); | 71 | { |
72 | XmlConfigSource source = new XmlConfigSource(filePath); | ||
73 | ReadItemsFromFile(source); | ||
74 | } | ||
75 | catch (XmlException e) | ||
76 | { | ||
77 | MainLog.Instance.Error("INVENTORY", "Error loading " + filePath + ": " + e.ToString()); | ||
78 | } | ||
70 | } | 79 | } |
71 | } | 80 | } |
72 | 81 | ||