mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-15 01:08:27 +00:00
Improved how AI Studio saves its files (#1201)
This commit is contained in:
1 parent
b7255694cd
commit
dc97db256e
24 files changed
+626
-258
No files matched your search
@@ -81,19 +81,8 @@ public static partial class WorkspaceBehaviour
|
||||
return true;
|
||||
|
||||
var lastEditTime = File.GetLastWriteTimeUtc(chatPath);
|
||||
var temporaryPath = Path.Join(chatDirectory, $".thread-{Guid.NewGuid():N}.tmp");
|
||||
try
|
||||
{
|
||||
await File.WriteAllTextAsync(temporaryPath, json, Encoding.UTF8, token);
|
||||
File.Move(temporaryPath, chatPath, overwrite: true);
|
||||
File.SetLastWriteTimeUtc(chatPath, lastEditTime);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (File.Exists(temporaryPath))
|
||||
File.Delete(temporaryPath);
|
||||
}
|
||||
|
||||
await AtomicFile.WriteTextAsync(chatPath, json, Encoding.UTF8, token, logger: LOG);
|
||||
File.SetLastWriteTimeUtc(chatPath, lastEditTime);
|
||||
return true;
|
||||
}
|
||||
catch (Exception exception) when (exception is JsonException or NotSupportedException)
|
||||
|
||||
Reference in new issue
Block a user