From 851b9362177be99ef222fcb6d75014b0093cd508 Mon Sep 17 00:00:00 2001 From: ig Date: Fri, 1 Sep 2023 11:11:09 +0200 Subject: [PATCH] only write config file when contents have changed (memo) --- csharp/App/SaliMax/src/SystemConfig/Config.cs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/csharp/App/SaliMax/src/SystemConfig/Config.cs b/csharp/App/SaliMax/src/SystemConfig/Config.cs index c096ca5aa..8613a63ce 100644 --- a/csharp/App/SaliMax/src/SystemConfig/Config.cs +++ b/csharp/App/SaliMax/src/SystemConfig/Config.cs @@ -38,7 +38,7 @@ public class Config //TODO: let IE choose from config files (Json) and connect t public required DeviceConfig Devices { get; set; } public required S3Config? S3 { get; set; } - + private static String? LastSavedData { get; set; } #if DEBUG public static Config Default => new() @@ -121,6 +121,12 @@ public class Config //TODO: let IE choose from config files (Json) and connect t try { var jsonString = Serialize(this, JsonOptions); + + if (LastSavedData == jsonString) + return; + + LastSavedData = jsonString; + File.WriteAllText(configFilePath, jsonString); } catch (Exception e)