Avoid writing script state to the filesystem if the state has not changed.

Remove the unneccessary double check that was only used to provide a
meaningless warning message for a corner case.
0.6.5-rc1
Melanie Thielker 2009-03-26 14:28:00 +00:00
parent c8aaf538e4
commit fcab3510b3
1 changed files with 19 additions and 14 deletions

View File

@ -92,6 +92,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
private StateSource m_stateSource;
private bool m_postOnRez;
private bool m_startedFromSavedState = false;
private string m_CurrentState = String.Empty;
//private ISponsor m_ScriptSponsor;
private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>>
@ -870,21 +871,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
string xml = ScriptSerializer.Serialize(this);
try
if (m_CurrentState != xml)
{
FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), m_ItemID.ToString() + ".state"));
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
Byte[] buf = enc.GetBytes(xml);
fs.Write(buf, 0, buf.Length);
fs.Close();
}
catch(Exception e)
{
m_log.Error("Unable to save xml\n"+e.ToString());
}
if (!File.Exists(Path.Combine(Path.GetDirectoryName(assembly), m_ItemID.ToString() + ".state")))
{
throw new Exception("Completed persistence save, but no file was created");
try
{
FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), m_ItemID.ToString() + ".state"));
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
Byte[] buf = enc.GetBytes(xml);
fs.Write(buf, 0, buf.Length);
fs.Close();
}
catch(Exception e)
{
m_log.Error("Unable to save xml\n"+e.ToString());
}
//if (!File.Exists(Path.Combine(Path.GetDirectoryName(assembly), m_ItemID.ToString() + ".state")))
//{
// throw new Exception("Completed persistence save, but no file was created");
//}
m_CurrentState = xml;
}
}