<commit_before>﻿using Lucid.Web.Utility;
using MvcFolders;

namespace Lucid.Web
{
    public class LucidApplication : System.Web.HttpApplication
    {
        public static Startup Startup = new Startup();

        protected void Application_Start()
        {
            Startup.Init();

            FeatureFolders.Register(typeof(LucidController).Assembly, "Lucid.Web.App");
        }
    }
}<commit_msg>Unzip the new version if it exists<commit_after>﻿using System.IO;
using System.Web;
using System.Web.Hosting;
using ICSharpCode.SharpZipLib.Core;
using ICSharpCode.SharpZipLib.Zip;
using Lucid.Web.Utility;
using MvcFolders;

namespace Lucid.Web
{
    public class LucidApplication : System.Web.HttpApplication
    {
        public static Startup Startup = new Startup();

        protected void Application_Start()
        {
            if (NewVersion())
                return;

            Startup.Init();

            FeatureFolders.Register(typeof(LucidController).Assembly, "Lucid.Web.App");
        }

        private bool NewVersion()
        {
            var packagedZip = HostingEnvironment.MapPath("~/Packaged.zip");

            if (!File.Exists(packagedZip))
                return false;

            var webFolder = HostingEnvironment.MapPath("~");
            var buffer = new byte[4096];

            using (var zipFile = new ZipFile(packagedZip))
                foreach (ZipEntry zipEntry in zipFile)
                {
                    var outFile = Path.Combine(webFolder, zipEntry.Name);
                    Directory.CreateDirectory(Path.GetDirectoryName(outFile));

                    using (var streamWriter = File.Create(outFile))
                        StreamUtils.Copy(zipFile.GetInputStream(zipEntry), streamWriter, buffer);
                }

            var deployedZip = HostingEnvironment.MapPath("~/Deployed.zip");
            File.Move(packagedZip, deployedZip);

            // get the client to re-load
            if (HttpContext.Current != null && HttpContext.Current.Request != null && HttpContext.Current.Response != null)
                HttpContext.Current.Response.Redirect(HttpContext.Current.Request.Url.ToString(), false);

            return true;
        }
    }
}
{'fraction_non_alphanumeric': 0.09806567701304543, 'fraction_numerical': 0.001799370220422852, 'mean_word_length': 2.172610556348074, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1968818', 'n_tokens_mistral': 618, 'n_tokens_neox': 575, 'n_words': 123}