From e669c062e6ee1af28d0a113604241cfd2d52457c Mon Sep 17 00:00:00 2001 From: venizelou andreas Date: Sat, 20 Apr 2024 13:21:10 +0300 Subject: [PATCH] Clean config --- Protest/Http/Cache.cs | 16 +++++++++------- Protest/Misc/Configuration.cs | 13 +++++++++---- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/Protest/Http/Cache.cs b/Protest/Http/Cache.cs index e2ccb62e..d087e0e9 100644 --- a/Protest/Http/Cache.cs +++ b/Protest/Http/Cache.cs @@ -92,13 +92,15 @@ public Cache(string path) { if (_deflate > 0) { Console.WriteLine($" Deflate : {100 * _deflate / (_raw + 1),5}% {_raw,10} -> {_deflate,8}"); } if (_brotli > 0) { Console.WriteLine($" Brotli : {100 * _brotli / (_raw + 1),5}% {_raw,10} -> {_brotli,8}"); } Console.WriteLine(); - - FileSystemWatcher watcher = new FileSystemWatcher(path); - watcher.EnableRaisingEvents = true; - watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.LastWrite; - watcher.Filter = "*"; - watcher.IncludeSubdirectories = true; - watcher.Changed += OnFileChanged; + + if (Directory.Exists(path)) { + FileSystemWatcher watcher = new FileSystemWatcher(path); + watcher.EnableRaisingEvents = true; + watcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.DirectoryName | NotifyFilters.LastWrite; + watcher.Filter = "*"; + watcher.IncludeSubdirectories = true; + watcher.Changed += OnFileChanged; + } #endif GC.Collect(); diff --git a/Protest/Misc/Configuration.cs b/Protest/Misc/Configuration.cs index 66842a89..18229009 100644 --- a/Protest/Misc/Configuration.cs +++ b/Protest/Misc/Configuration.cs @@ -129,8 +129,13 @@ internal static void CreateDefault() { builder.AppendLine($"db_key = {DB_KEY_STRING}"); builder.AppendLine(); +#if DEBUG builder.AppendLine($"front_path = {front_path}"); builder.AppendLine(); +#else + builder.AppendLine($"#front_path = {front_path}"); + builder.AppendLine(); +#endif builder.AppendLine($"force_registry_keys = {force_registry_keys.ToString().ToLower()}"); builder.AppendLine("accept_xff_header = false"); @@ -146,10 +151,10 @@ internal static void CreateDefault() { builder.AppendLine(); builder.AppendLine(); - builder.AppendLine("###"); - builder.AppendLine("### Use NETSH to bind an SSL certificate with your https endpoint:"); - builder.AppendLine($"### netsh http add sslcert ipport=0.0.0.0:443 certhash=[thumbprint] appid={{{Data.GUID}}}"); - builder.AppendLine("###"); + builder.AppendLine("##"); + builder.AppendLine("## Use NETSH to bind an SSL certificate with your https endpoint:"); + builder.AppendLine($"## netsh http add sslcert ipport=0.0.0.0:443 certhash=[thumbprint] appid={{{Data.GUID}}}"); + builder.AppendLine("##"); File.WriteAllText(Data.FILE_CONFIG, builder.ToString()); }