From 946db5461c8262d3b957e42ed7a90feb447c618b Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Sat, 17 Nov 2007 05:53:12 +0000 Subject: catch exceptions when loading malformed xml files --- .../Communications/Cache/AssetServerBase.cs | 38 +++++++++++++--------- 1 file changed, 23 insertions(+), 15 deletions(-) (limited to 'OpenSim/Framework/Communications/Cache/AssetServerBase.cs') 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; using System.Collections.Generic; using System.IO; using System.Threading; +using System.Xml; using libsecondlife; using Nini.Config; using OpenSim.Framework.Console; @@ -148,22 +149,29 @@ namespace OpenSim.Framework.Communications.Cache string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml"); if (File.Exists(filePath)) { - XmlConfigSource source = new XmlConfigSource(filePath); - - for (int i = 0; i < source.Configs.Count; i++) + try + { + XmlConfigSource source = new XmlConfigSource(filePath); + + for (int i = 0; i < source.Configs.Count; i++) + { + // System.Console.WriteLine("loading asset into database"); + string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); + string name = source.Configs[i].GetString("name", ""); + sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); + sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0); + string fileName = source.Configs[i].GetString("fileName", ""); + + AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); + + newAsset.Type = type; + newAsset.InvType = invType; + assets.Add(newAsset); + } + } + catch (XmlException e) { - // System.Console.WriteLine("loading asset into database"); - string assetIdStr = source.Configs[i].GetString("assetID", LLUUID.Random().ToStringHyphenated()); - string name = source.Configs[i].GetString("name", ""); - sbyte type = (sbyte) source.Configs[i].GetInt("assetType", 0); - sbyte invType = (sbyte) source.Configs[i].GetInt("inventoryType", 0); - string fileName = source.Configs[i].GetString("fileName", ""); - - AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false); - - newAsset.Type = type; - newAsset.InvType = invType; - assets.Add(newAsset); + MainLog.Instance.Error("ASSETS", "Error loading " + filePath + ": " + e.ToString()); } } assets.ForEach(action); -- cgit v1.1