From 2131bf181755f6a40f82c5429b22f7e97b900ac8 Mon Sep 17 00:00:00 2001 From: Thorsten Sommer Date: Wed, 1 Jan 2025 17:15:04 +0100 Subject: [PATCH] Improved the save operation of settings by using a temporary file (#237) --- app/MindWork AI Studio/Settings/SettingsManager.cs | 4 +++- app/MindWork AI Studio/wwwroot/changelog/v0.9.23.md | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/MindWork AI Studio/Settings/SettingsManager.cs b/app/MindWork AI Studio/Settings/SettingsManager.cs index de1aebe..0fa3e18 100644 --- a/app/MindWork AI Studio/Settings/SettingsManager.cs +++ b/app/MindWork AI Studio/Settings/SettingsManager.cs @@ -118,8 +118,10 @@ public sealed class SettingsManager(ILogger 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."); } diff --git a/app/MindWork AI Studio/wwwroot/changelog/v0.9.23.md b/app/MindWork AI Studio/wwwroot/changelog/v0.9.23.md index e1c4498..499a9dd 100644 --- a/app/MindWork AI Studio/wwwroot/changelog/v0.9.23.md +++ b/app/MindWork AI Studio/wwwroot/changelog/v0.9.23.md @@ -2,5 +2,6 @@ - Added an ERI server coding assistant as a preview feature behind the RAG feature flag. This helps you implement an ERI server to gain access to, e.g., your enterprise data from within AI Studio. - Improved provider requests by handling rate limits by retrying requests. - Improved the creation of the "the bias of the day" workspace; create that workspace only when the bias of the day feature is used. +- Improved the save operation of settings by using a temporary file to avoid data loss in rare cases. - Fixed layout issues when selecting `other` items (e.g., programming languages). - Fixed a bug about the bias of the day workspace when the workspace component was hidden. \ No newline at end of file