mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-27 15:07:03 +01:00
Brute force config saving
This commit is contained in:
@@ -102,20 +102,23 @@ namespace TGS.Server
|
||||
/// Properly shuts down all <see cref="ChatProviders"/>
|
||||
/// </summary>
|
||||
void DisposeChat()
|
||||
{
|
||||
SaveChatConfig();
|
||||
foreach (var ChatProvider in ChatProviders)
|
||||
ChatProvider.Dispose();
|
||||
ChatProviders = null;
|
||||
}
|
||||
|
||||
void SaveChatConfig()
|
||||
{
|
||||
var infosList = new List<IList<string>>();
|
||||
|
||||
foreach (var ChatProvider in ChatProviders)
|
||||
{
|
||||
infosList.Add(ChatProvider.ProviderInfo().DataFields);
|
||||
ChatProvider.Dispose();
|
||||
}
|
||||
ChatProviders = null;
|
||||
|
||||
var rawdata = JsonConvert.SerializeObject(infosList, Formatting.Indented);
|
||||
|
||||
Config.ChatProviderData = Interface.Helpers.EncryptData(rawdata, out string entrp);
|
||||
Config.ChatProviderEntropy = entrp;
|
||||
Config.Save();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -166,6 +169,7 @@ namespace TGS.Server
|
||||
catch
|
||||
{
|
||||
Config.ChatProviderData = UninitializedString;
|
||||
Config.Save();
|
||||
}
|
||||
}
|
||||
//if we get here we want to retry
|
||||
@@ -186,7 +190,10 @@ namespace TGS.Server
|
||||
{
|
||||
foreach (var ChatProvider in ChatProviders)
|
||||
if (info.Provider == ChatProvider.ProviderInfo().Provider)
|
||||
{
|
||||
SaveChatConfig();
|
||||
return ChatProvider.SetProviderInfo(info);
|
||||
}
|
||||
return "Error: Invalid provider: " + info.Provider.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -663,6 +663,7 @@ namespace TGS.Server
|
||||
lock (CompilerLock)
|
||||
{
|
||||
Config.ProjectName = projectName;
|
||||
Config.Save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -237,6 +237,7 @@ namespace TGS.Server
|
||||
lock (watchdogLock)
|
||||
{
|
||||
Config.Port = new_port;
|
||||
Config.Save();
|
||||
RequestRestart();
|
||||
}
|
||||
}
|
||||
@@ -665,6 +666,7 @@ namespace TGS.Server
|
||||
{
|
||||
needReboot = Config.Security != level;
|
||||
Config.Security = level;
|
||||
Config.Save();
|
||||
}
|
||||
if (needReboot)
|
||||
RequestRestart();
|
||||
@@ -681,6 +683,7 @@ namespace TGS.Server
|
||||
public void SetAutostart(bool on)
|
||||
{
|
||||
Config.Autostart = on;
|
||||
Config.Save();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -757,6 +760,7 @@ namespace TGS.Server
|
||||
if (diff)
|
||||
{
|
||||
Config.Webclient = on;
|
||||
Config.Save();
|
||||
RequestRestart();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1093,6 +1093,7 @@ namespace TGS.Server
|
||||
public void SetCommitterName(string newName)
|
||||
{
|
||||
Config.CommitterName = newName;
|
||||
Config.Save();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1105,6 +1106,7 @@ namespace TGS.Server
|
||||
public void SetCommitterEmail(string newEmail)
|
||||
{
|
||||
Config.CommitterEmail = newEmail;
|
||||
Config.Save();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1403,6 +1405,7 @@ namespace TGS.Server
|
||||
}
|
||||
}
|
||||
Config.AutoUpdateInterval = newInterval;
|
||||
Config.Save();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
@@ -1458,6 +1461,7 @@ namespace TGS.Server
|
||||
public void SetPushTestmergeCommits(bool newValue)
|
||||
{
|
||||
Config.PushTestmergeCommits = newValue;
|
||||
Config.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -218,7 +218,9 @@ namespace TGS.Server
|
||||
/// <inheritdoc />
|
||||
public void Save()
|
||||
{
|
||||
var data = JsonConvert.SerializeObject(this, Formatting.Indented);
|
||||
string data;
|
||||
lock(this)
|
||||
data = JsonConvert.SerializeObject(this, Formatting.Indented);
|
||||
var path = Path.Combine(Directory, JSONFilename);
|
||||
File.WriteAllText(path, data);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user