From 7bd1601a3fed74c9caa9b00869734eb14aab6ebe Mon Sep 17 00:00:00 2001 From: "Justin Clark-Casey (justincc)" Date: Tue, 19 Jun 2012 01:53:50 +0100 Subject: [PATCH] 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. --- .../Region/ScriptEngine/XEngine/XEngine.cs | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index 4ec57e4be3..57cd8eba49 100644 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -1743,6 +1743,8 @@ namespace OpenSim.Region.ScriptEngine.XEngine public bool SetXMLState(UUID itemID, string xml) { +// m_log.DebugFormat("[XEngine]: Writing state for script item with ID {0}", itemID); + if (xml == String.Empty) return false; @@ -1803,31 +1805,34 @@ namespace OpenSim.Region.ScriptEngine.XEngine { using (FileStream fs = File.Create(path)) { +// m_log.DebugFormat("[XEngine]: Writing assembly file {0}", path); + fs.Write(filedata, 0, filedata.Length); - fs.Close(); } } catch (IOException ex) { // 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 { using (FileStream fs = File.Create(path + ".text")) { using (StreamWriter sw = new StreamWriter(fs)) { +// m_log.DebugFormat("[XEngine]: Writing .text file {0}", textpath); + sw.Write(base64); - sw.Close(); } - fs.Close(); } } catch (IOException ex) { // 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)) { +// m_log.DebugFormat("[XEngine]: Writing state file {0}", statepath); + ssw.Write(stateE.OuterXml); - ssw.Close(); } - sfs.Close(); } } catch (IOException ex) { // 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"); @@ -1867,16 +1872,16 @@ namespace OpenSim.Region.ScriptEngine.XEngine { using (StreamWriter msw = new StreamWriter(mfs)) { +// m_log.DebugFormat("[XEngine]: Writing linemap file {0}", mappath); + msw.Write(mapE.InnerText); - msw.Close(); } - mfs.Close(); } } catch (IOException ex) { // 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); } }