Improved the save operation of settings by using a temporary file (#237)

This commit is contained in:
Thorsten Sommer authored and GitHub committed 2025-01-01 17:15:04 +01:00
1 parent 8cbef49d89
commit 2131bf1817
2 files changed
+4 -1

No files matched your search

@@ -118,8 +118,10 @@ public sealed class SettingsManager(ILogger<SettingsManager> logger)
}
var settingsJson = JsonSerializer.Serialize(this.ConfigurationData, JSON_OPTIONS);
await File.WriteAllTextAsync(settingsPath, settingsJson);
var tempFile = Path.GetTempFileName();
await File.WriteAllTextAsync(tempFile, settingsJson);
File.Move(tempFile, settingsPath, true);
this.logger.LogInformation("Stored the settings to the file system.");
}