catch exceptions when loading malformed xml files
parent
c5ddbd3254
commit
946db5461c
|
@ -2,6 +2,7 @@ using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using System.Xml;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
using OpenSim.Framework.Console;
|
using OpenSim.Framework.Console;
|
||||||
|
@ -148,22 +149,29 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml");
|
string filePath = Path.Combine(Util.configDir(), "OpenSimAssetSet.xml");
|
||||||
if (File.Exists(filePath))
|
if (File.Exists(filePath))
|
||||||
{
|
{
|
||||||
XmlConfigSource source = new XmlConfigSource(filePath);
|
try
|
||||||
|
|
||||||
for (int i = 0; i < source.Configs.Count; i++)
|
|
||||||
{
|
{
|
||||||
// System.Console.WriteLine("loading asset into database");
|
XmlConfigSource source = new XmlConfigSource(filePath);
|
||||||
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);
|
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", "");
|
||||||
|
|
||||||
newAsset.Type = type;
|
AssetBase newAsset = CreateAsset(assetIdStr, name, fileName, false);
|
||||||
newAsset.InvType = invType;
|
|
||||||
assets.Add(newAsset);
|
newAsset.Type = type;
|
||||||
|
newAsset.InvType = invType;
|
||||||
|
assets.Add(newAsset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (XmlException e)
|
||||||
|
{
|
||||||
|
MainLog.Instance.Error("ASSETS", "Error loading " + filePath + ": " + e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assets.ForEach(action);
|
assets.ForEach(action);
|
||||||
|
|
|
@ -27,8 +27,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Xml;
|
||||||
using libsecondlife;
|
using libsecondlife;
|
||||||
using Nini.Config;
|
using Nini.Config;
|
||||||
|
using OpenSim.Framework.Console;
|
||||||
|
|
||||||
namespace OpenSim.Framework.Communications.Cache
|
namespace OpenSim.Framework.Communications.Cache
|
||||||
{
|
{
|
||||||
|
@ -65,8 +67,15 @@ namespace OpenSim.Framework.Communications.Cache
|
||||||
string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml");
|
string filePath = Path.Combine(Util.configDir(), "OpenSimLibrary.xml");
|
||||||
if (File.Exists(filePath))
|
if (File.Exists(filePath))
|
||||||
{
|
{
|
||||||
XmlConfigSource source = new XmlConfigSource(filePath);
|
try
|
||||||
ReadItemsFromFile(source);
|
{
|
||||||
|
XmlConfigSource source = new XmlConfigSource(filePath);
|
||||||
|
ReadItemsFromFile(source);
|
||||||
|
}
|
||||||
|
catch (XmlException e)
|
||||||
|
{
|
||||||
|
MainLog.Instance.Error("INVENTORY", "Error loading " + filePath + ": " + e.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -166,8 +166,16 @@ namespace OpenSim.Framework
|
||||||
if (configurationFilename.Trim() != "")
|
if (configurationFilename.Trim() != "")
|
||||||
{
|
{
|
||||||
configurationPlugin.SetFileName(configurationFilename);
|
configurationPlugin.SetFileName(configurationFilename);
|
||||||
configurationPlugin.LoadData();
|
try
|
||||||
useFile = true;
|
{
|
||||||
|
configurationPlugin.LoadData();
|
||||||
|
useFile = true;
|
||||||
|
}
|
||||||
|
catch (XmlException e)
|
||||||
|
{
|
||||||
|
MainLog.Instance.Error("Error loading " + configurationFilename + ": " + e.ToString());
|
||||||
|
useFile = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -189,7 +197,6 @@ namespace OpenSim.Framework
|
||||||
bool ignoreNextFromConfig = false;
|
bool ignoreNextFromConfig = false;
|
||||||
while (convertSuccess == false)
|
while (convertSuccess == false)
|
||||||
{
|
{
|
||||||
|
|
||||||
string console_result = "";
|
string console_result = "";
|
||||||
string attribute = null;
|
string attribute = null;
|
||||||
if (useFile || (!useFile && configurationFromXMLNode != null))
|
if (useFile || (!useFile && configurationFromXMLNode != null))
|
||||||
|
@ -228,7 +235,6 @@ namespace OpenSim.Framework
|
||||||
//Dont Ask! Just use default
|
//Dont Ask! Just use default
|
||||||
console_result = configOption.configurationDefault;
|
console_result = configOption.configurationDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -292,7 +298,6 @@ namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
convertSuccess = true;
|
convertSuccess = true;
|
||||||
return_result = intResult;
|
return_result = intResult;
|
||||||
|
|
||||||
}
|
}
|
||||||
errorMessage = "a signed 32 bit integer (int)";
|
errorMessage = "a signed 32 bit integer (int)";
|
||||||
break;
|
break;
|
||||||
|
@ -347,7 +352,6 @@ namespace OpenSim.Framework
|
||||||
{
|
{
|
||||||
convertSuccess = true;
|
convertSuccess = true;
|
||||||
return_result = uintResult;
|
return_result = uintResult;
|
||||||
|
|
||||||
}
|
}
|
||||||
errorMessage = "an unsigned 32 bit integer (uint)";
|
errorMessage = "an unsigned 32 bit integer (uint)";
|
||||||
break;
|
break;
|
||||||
|
@ -387,7 +391,6 @@ namespace OpenSim.Framework
|
||||||
configurationPlugin.SetAttribute(configOption.configurationKey, console_result);
|
configurationPlugin.SetAttribute(configOption.configurationKey, console_result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!this.resultFunction(configOption.configurationKey, return_result))
|
if (!this.resultFunction(configOption.configurationKey, return_result))
|
||||||
{
|
{
|
||||||
Console.MainLog.Instance.Notice("The handler for the last configuration option denied that input, please try again.");
|
Console.MainLog.Instance.Notice("The handler for the last configuration option denied that input, please try again.");
|
||||||
|
|
Loading…
Reference in New Issue