<commit_before>using System;
using System.Collections.Generic;
using System.Text;
using System.Timers;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using Nini.Config;

namespace Aurora.Modules
{
    public class VersionControlModule : ISharedRegionModule
    {
        private bool m_Enabled = false;

        //Auto OAR configs
        private Timer m_autoOARTimer = null;
        private bool m_autoOAREnabled = false;
        private float m_autoOARTime = 1; //In days

        private int nextVersion = 1;

        public string Name
        {
            get { return "VersionControlModule"; }
        }

        public Type ReplaceableInterface
        {
            get { return null; }
        }

        public void Initialise(Nini.Config.IConfigSource source)
        {
            if (source.Configs["VersionControl"] == null)
                return;
            IConfig config = source.Configs["VersionControl"];
            m_Enabled = config.GetBoolean("Enabled", false);

            //Auto OAR config
            m_autoOAREnabled = config.GetBoolean("AutoVersionEnabled", false);
            m_autoOARTime = config.GetFloat("AutoVersionTime", 1);
        }

        public void Close()
        {
        }

        public void PostInitialise()
        {
        }

        public void AddRegion(Scene scene)
        {
        }

        public void RemoveRegion(Scene scene)
        {
        }

        public void RegionLoaded(Scene scene)
        {
            if (!m_Enabled)
                return;

            if (m_autoOAREnabled)
            {
                m_autoOARTimer = new Timer(m_autoOARTime * 1000 * 60 * 60 * 24);//Time in days
                m_autoOARTimer.Elapsed += SaveOAR;
                m_autoOARTimer.Enabled = true;
            }
            //scene.AddCommand(this, "save version", "save version <description>", "Saves the current region as the next incremented version in the version control module.", SaveVersion);
        }

        private void SaveOAR(object sender, ElapsedEventArgs e)
        {
            SaveNext((Scene)MainConsole.Instance.ConsoleScene, "AutomaticBackup");
        }

        protected void SaveVersion(string module, string[] cmdparams)
        {
            if (cmdparams.Length < 3)
                return;

            string Desc = "";
            cmdparams[0] = "";
            cmdparams[1] = "";
            foreach(string param in cmdparams)
            {
                Desc += param;
            }

            SaveNext((Scene)MainConsole.Instance.ConsoleScene, Desc);
        }

        public void SaveNext(Scene nextScene, string Description)
        {
            Scene scene = (Scene)MainConsole.Instance.ConsoleScene; //Switch back later
            MainConsole.Instance.RunCommand("change region " + nextScene.RegionInfo.RegionName);
            string tag = "";
            tag += "Region." + nextScene.RegionInfo.RegionName;
            tag += ".Desc." + Description;
            tag += ".Version." + nextVersion;
            tag += ".Date." + DateTime.Now.ToString();
            nextVersion++;
            MainConsole.Instance.RunCommand("save oar " + tag + ".vc.oar");<commit_msg>Fix the path to the auto oar backup which was using the date with \ in the path, which was breaking it.<commit_after>using System;
using System.Collections.Generic;
using System.Text;
using System.Timers;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using Nini.Config;

namespace Aurora.Modules
{
    public class VersionControlModule : ISharedRegionModule
    {
        private bool m_Enabled = false;

        //Auto OAR configs
        private Timer m_autoOARTimer = null;
        private bool m_autoOAREnabled = false;
        private float m_autoOARTime = 1; //In days

        private int nextVersion = 1;

        public string Name
        {
            get { return "VersionControlModule"; }
        }

        public Type ReplaceableInterface
        {
            get { return null; }
        }

        public void Initialise(Nini.Config.IConfigSource source)
        {
            if (source.Configs["VersionControl"] == null)
                return;
            IConfig config = source.Configs["VersionControl"];
            m_Enabled = config.GetBoolean("Enabled", false);

            //Auto OAR config
            m_autoOAREnabled = config.GetBoolean("AutoVersionEnabled", false);
            m_autoOARTime = config.GetFloat("AutoVersionTime", 1);
        }

        public void Close()
        {
        }

        public void PostInitialise()
        {
        }

        public void AddRegion(Scene scene)
        {
        }

        public void RemoveRegion(Scene scene)
        {
        }

        public void RegionLoaded(Scene scene)
        {
            if (!m_Enabled)
                return;

            if (m_autoOAREnabled)
            {
                m_autoOARTimer = new Timer(m_autoOARTime * 1000 * 60 * 60 * 24);//Time in days
                m_autoOARTimer.Elapsed += SaveOAR;
                m_autoOARTimer.Enabled = true;
            }
            //scene.AddCommand(this, "save version", "save version <description>", "Saves the current region as the next incremented version in the version control module.", SaveVersion);
        }

        private void SaveOAR(object sender, ElapsedEventArgs e)
        {
            SaveNext((Scene)MainConsole.Instance.ConsoleScene, "AutomaticBackup");
        }

        protected void SaveVersion(string module, string[] cmdparams)
        {
            if (cmdparams.Length < 3)
                return;

            string Desc = "";
            cmdparams[0] = "";
            cmdparams[1] = "";
            foreach(string param in cmdparams)
            {
                Desc += param;
            }

            SaveNext((Scene)MainConsole.Instance.ConsoleScene, Desc);
        }

        public void SaveNext(Scene nextScene, string Description)
        {
            Scene scene = (Scene)MainConsole.Instance.ConsoleScene; //Switch back later
            MainConsole.Instance.RunCommand("change region " + nextScene.RegionInfo.RegionName);
            string tag = "";
            tag += "Region." + nextScene.RegionInfo.RegionName;
            tag += ".Desc." + Description;
            tag += ".Version." + nextVersion;
            tag += ".Date." + DateTime.Now.Year + "." + DateTime.Now.Month + "." + DateTime.Now.Day + "." + DateTime.Now.Hour;
            nextVersion++;
            MainConsole.Instance.RunCommand("save oar " + tag + ".vc.oar");
{'fraction_non_alphanumeric': 0.09454983438723276, 'fraction_numerical': 0.004817825956037338, 'mean_word_length': 1.8304218150830849, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6888915', 'n_tokens_mistral': 1772, 'n_tokens_neox': 1684, 'n_words': 428}