From 049bce4d003f6854868306c7d98f7b5a501cb047 Mon Sep 17 00:00:00 2001 From: Sean McNamara Date: Tue, 12 Apr 2011 01:14:21 -0400 Subject: Fixup the global defaults config parsing code. --- .../World/AutoBackup/AutoBackupModule.cs | 40 ++++++++++++++-------- 1 file changed, 25 insertions(+), 15 deletions(-) (limited to 'OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs') diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs index e52e9cb..364697b 100644 --- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs +++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs @@ -238,7 +238,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup defTimer.AutoReset = true; defTimer.Start (); - AutoBackupModuleState abms = ParseConfig(null, false); + AutoBackupModuleState abms = ParseConfig(null, true); m_log.Debug("[AUTO BACKUP]: Config for default"); m_log.Debug(abms.ToString()); } @@ -262,16 +262,23 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup if (!m_Enabled) return; - AutoBackupModuleState abms = states[scene]; - Timer timer = abms.GetTimer (); - List list = timerMap[timer]; - list.Remove (scene); - if (list.Count == 0) { - timerMap.Remove (timer); - timers.Remove (timer.Interval); - timer.Close (); + if(states.ContainsKey(scene)) + { + AutoBackupModuleState abms = states[scene]; + + //Remove this scene out of the timer map list + Timer timer = abms.GetTimer (); + List list = timerMap[timer]; + list.Remove (scene); + + //Shut down the timer if this was the last scene for the timer + if (list.Count == 0) { + timerMap.Remove (timer); + timers.Remove (timer.Interval); + timer.Close (); + } + states.Remove(scene); } - states.Remove(scene); } void IRegionModuleBase.RegionLoaded (Framework.Scenes.Scene scene) @@ -283,9 +290,9 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup if (scene == null) return; - AutoBackupModuleState abms = ParseConfig(scene, true); + AutoBackupModuleState abms = ParseConfig(scene, false); m_log.Debug("[AUTO BACKUP]: Config for " + scene.RegionInfo.RegionName); - m_log.Debug(abms.ToString()); + m_log.Debug((abms == null ? "DEFAULT" : abms.ToString())); } AutoBackupModuleState ParseConfig (IScene scene, bool parseDefault) @@ -322,13 +329,16 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup if(state == null && tmpEnabled != defaultState.GetEnabled()) //Varies from default state { state = new AutoBackupModuleState(); - state.SetEnabled (tmpEnabled); + } + + if(state != null) + { + state.SetEnabled (tmpEnabled); } //If you don't want AutoBackup, we stop. - if ((state == null && !defaultState.GetEnabled()) || !state.GetEnabled ()) { + if ((state == null && !defaultState.GetEnabled()) || (state != null && !state.GetEnabled ())) { m_log.Info ("[AUTO BACKUP]: Region " + sRegionLabel + " is NOT AutoBackup enabled."); - state = defaultState; return state; } else { m_log.Info ("[AUTO BACKUP]: Region " + sRegionLabel + " is AutoBackup ENABLED."); -- cgit v1.1