minor: Add a little more detail to IOException logging in XEngine.SetXMLState()

Also removes superflous Close() commands for statements taking place within using() constructs
Also adds some comment out debug log messages for future use.
0.7.3-extended
Justin Clark-Casey (justincc) 2012-06-19 01:53:50 +01:00
parent 3aef006e78
commit 7bd1601a3f
1 changed files with 16 additions and 11 deletions

View File

@ -1743,6 +1743,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine
public bool SetXMLState(UUID itemID, string xml) public bool SetXMLState(UUID itemID, string xml)
{ {
// m_log.DebugFormat("[XEngine]: Writing state for script item with ID {0}", itemID);
if (xml == String.Empty) if (xml == String.Empty)
return false; return false;
@ -1803,31 +1805,34 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{ {
using (FileStream fs = File.Create(path)) using (FileStream fs = File.Create(path))
{ {
// m_log.DebugFormat("[XEngine]: Writing assembly file {0}", path);
fs.Write(filedata, 0, filedata.Length); fs.Write(filedata, 0, filedata.Length);
fs.Close();
} }
} }
catch (IOException ex) catch (IOException ex)
{ {
// if there already exists a file at that location, it may be locked. // if there already exists a file at that location, it may be locked.
m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); m_log.ErrorFormat("[XEngine]: Error whilst writing assembly file {0}, {1}", path, ex.Message);
} }
string textpath = path + ".text";
try try
{ {
using (FileStream fs = File.Create(path + ".text")) using (FileStream fs = File.Create(path + ".text"))
{ {
using (StreamWriter sw = new StreamWriter(fs)) using (StreamWriter sw = new StreamWriter(fs))
{ {
// m_log.DebugFormat("[XEngine]: Writing .text file {0}", textpath);
sw.Write(base64); sw.Write(base64);
sw.Close();
} }
fs.Close();
} }
} }
catch (IOException ex) catch (IOException ex)
{ {
// if there already exists a file at that location, it may be locked. // if there already exists a file at that location, it may be locked.
m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", path, ex.Message); m_log.ErrorFormat("[XEngine]: Error whilst writing .text file {0}, {1}", textpath, ex.Message);
} }
} }
} }
@ -1841,16 +1846,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{ {
using (StreamWriter ssw = new StreamWriter(sfs)) using (StreamWriter ssw = new StreamWriter(sfs))
{ {
// m_log.DebugFormat("[XEngine]: Writing state file {0}", statepath);
ssw.Write(stateE.OuterXml); ssw.Write(stateE.OuterXml);
ssw.Close();
} }
sfs.Close();
} }
} }
catch (IOException ex) catch (IOException ex)
{ {
// if there already exists a file at that location, it may be locked. // if there already exists a file at that location, it may be locked.
m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message); m_log.ErrorFormat("[XEngine]: Error whilst writing state file {0}, {1}", statepath, ex.Message);
} }
XmlNodeList mapL = rootE.GetElementsByTagName("LineMap"); XmlNodeList mapL = rootE.GetElementsByTagName("LineMap");
@ -1867,16 +1872,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine
{ {
using (StreamWriter msw = new StreamWriter(mfs)) using (StreamWriter msw = new StreamWriter(mfs))
{ {
// m_log.DebugFormat("[XEngine]: Writing linemap file {0}", mappath);
msw.Write(mapE.InnerText); msw.Write(mapE.InnerText);
msw.Close();
} }
mfs.Close();
} }
} }
catch (IOException ex) catch (IOException ex)
{ {
// if there already exists a file at that location, it may be locked. // if there already exists a file at that location, it may be locked.
m_log.ErrorFormat("[XEngine]: File {0} already exists! {1}", statepath, ex.Message); m_log.ErrorFormat("[XEngine]: Linemap file {0} already exists! {1}", mappath, ex.Message);
} }
} }