Skip to content

Commit 4bfa07c

Browse files
committed
Add setting to preserve custom NLog configuration on updates
- Introduced `OverwriteGlobalNLogConfigOnUpdate` setting to allow users to retain custom NLog configurations during updates. - Updated `UpdateManager` to respect this setting and prevent overwriting `NLog.config`.
1 parent 6ad02f4 commit 4bfa07c

3 files changed

Lines changed: 8 additions & 8 deletions

File tree

‎Torch.API/ITorchConfig.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ public interface ITorchConfig
4343
int GameUpdateRestartDelayMins { get; set; }
4444
bool EnableWhitelist { get; set; }
4545
List<ulong> Whitelist { get; set; }
46+
bool OverwriteGlobalNLogConfigOnUpdate { get; set; }
4647

4748
void Save(string path = null);
4849
}

‎Torch.Server/Managers/UpdateManager.cs‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
using System;
2-
using System.Collections.Generic;
32
using System.IO;
43
using System.IO.Compression;
5-
using System.IO.Packaging;
6-
using System.Linq;
7-
using System.Net;
8-
using System.Reflection;
9-
using System.Text;
10-
using System.Text.RegularExpressions;
114
using System.Threading;
12-
using System.Threading.Tasks;
135
using NLog;
146
using Torch.API;
157
using Torch.API.WebAPI;
@@ -99,6 +91,11 @@ private void UpdateFromZip(string zipFile, string extractPath)
9991
{
10092
if(file.Name == "NLog-user.config" && File.Exists(Path.Combine(extractPath, file.FullName)))
10193
continue;
94+
95+
// Torch will overwrite any user nlog settings and some want a different set of options. This allows them to keep theirs.
96+
if(file.Name == "NLog.config" && File.Exists(Path.Combine(extractPath, file.FullName)))
97+
if (!Torch.Config.OverwriteGlobalNLogConfigOnUpdate)
98+
continue;
10299

103100
var targetFile = Path.Combine(extractPath, file.FullName);
104101
Directory.CreateDirectory(Path.GetDirectoryName(targetFile));

‎Torch.Server/TorchConfig.cs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ public TorchBranchType BranchName
223223
[Display(Name = "Login Token", Description = "Steam GSLT (can be used if you have dynamic ip)", GroupName = "Server")]
224224
public string LoginToken { get => _loginToken; set => Set(value, ref _loginToken); }
225225

226+
[Display(Name = "Overwrite global NLog config on update.", Description = "This should ALWAYS be true UNLESS you know what you are doing. Breaking the default config may cause issues with logging. Just, no. Leave this alone.", GroupName = "Logging" )]
227+
public bool OverwriteGlobalNLogConfigOnUpdate { get; set; } = true;
226228

227229
public event PropertyChangedEventHandler PropertyChanged;
228230

0 commit comments

Comments
 (0)