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,6 +871,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
string xml = ScriptSerializer.Serialize(this);
if (m_CurrentState != xml)
{
try
{
FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), m_ItemID.ToString() + ".state"));
@ -882,9 +885,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
{
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");
//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;
}
}