Brute force config saving

This commit is contained in:
Cyberboss
2018-07-09 14:35:22 -04:00
parent 0b111e4294
commit 145a1622f0
5 changed files with 25 additions and 7 deletions
+13 -6
View File
@@ -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();
}
}
+1
View File
@@ -663,6 +663,7 @@ namespace TGS.Server
lock (CompilerLock)
{
Config.ProjectName = projectName;
Config.Save();
}
}
+4
View File
@@ -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();
}
}
+4
View File
@@ -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();
}
}
}
+3 -1
View File
@@ -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);
}