diff options
author | Melanie Thielker | 2009-03-26 14:28:00 +0000 |
---|---|---|
committer | Melanie Thielker | 2009-03-26 14:28:00 +0000 |
commit | fcab3510b379c812d675ef57ae7000f23d3a624b (patch) | |
tree | 62fdf985d5cb5a6cc87122e43bd53bb02f5f4f14 /OpenSim/Region/ScriptEngine/Shared/Instance | |
parent | - adding osGetAgents() which returns a list of all avatars in the region (diff) | |
download | opensim-SC_OLD-fcab3510b379c812d675ef57ae7000f23d3a624b.zip opensim-SC_OLD-fcab3510b379c812d675ef57ae7000f23d3a624b.tar.gz opensim-SC_OLD-fcab3510b379c812d675ef57ae7000f23d3a624b.tar.bz2 opensim-SC_OLD-fcab3510b379c812d675ef57ae7000f23d3a624b.tar.xz |
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.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Instance')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs index bcd4ccd..3884138 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Instance/ScriptInstance.cs | |||
@@ -92,6 +92,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
92 | private StateSource m_stateSource; | 92 | private StateSource m_stateSource; |
93 | private bool m_postOnRez; | 93 | private bool m_postOnRez; |
94 | private bool m_startedFromSavedState = false; | 94 | private bool m_startedFromSavedState = false; |
95 | private string m_CurrentState = String.Empty; | ||
95 | 96 | ||
96 | //private ISponsor m_ScriptSponsor; | 97 | //private ISponsor m_ScriptSponsor; |
97 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> | 98 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> |
@@ -870,21 +871,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance | |||
870 | 871 | ||
871 | string xml = ScriptSerializer.Serialize(this); | 872 | string xml = ScriptSerializer.Serialize(this); |
872 | 873 | ||
873 | try | 874 | if (m_CurrentState != xml) |
874 | { | ||
875 | FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), m_ItemID.ToString() + ".state")); | ||
876 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | ||
877 | Byte[] buf = enc.GetBytes(xml); | ||
878 | fs.Write(buf, 0, buf.Length); | ||
879 | fs.Close(); | ||
880 | } | ||
881 | catch(Exception e) | ||
882 | { | ||
883 | m_log.Error("Unable to save xml\n"+e.ToString()); | ||
884 | } | ||
885 | if (!File.Exists(Path.Combine(Path.GetDirectoryName(assembly), m_ItemID.ToString() + ".state"))) | ||
886 | { | 875 | { |
887 | throw new Exception("Completed persistence save, but no file was created"); | 876 | try |
877 | { | ||
878 | FileStream fs = File.Create(Path.Combine(Path.GetDirectoryName(assembly), m_ItemID.ToString() + ".state")); | ||
879 | System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding(); | ||
880 | Byte[] buf = enc.GetBytes(xml); | ||
881 | fs.Write(buf, 0, buf.Length); | ||
882 | fs.Close(); | ||
883 | } | ||
884 | catch(Exception e) | ||
885 | { | ||
886 | m_log.Error("Unable to save xml\n"+e.ToString()); | ||
887 | } | ||
888 | //if (!File.Exists(Path.Combine(Path.GetDirectoryName(assembly), m_ItemID.ToString() + ".state"))) | ||
889 | //{ | ||
890 | // throw new Exception("Completed persistence save, but no file was created"); | ||
891 | //} | ||
892 | m_CurrentState = xml; | ||
888 | } | 893 | } |
889 | } | 894 | } |
890 | 895 | ||