mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-11-04 21:07:21 +00:00
Kept the app responsive while a backup copies the index (#1062)
This commit is contained in:
1 parent
936043319c
commit
65857ca845
5 files changed
+64
-28
No files matched your search
+7
-2
@@ -590,9 +590,14 @@ public sealed partial class SqliteIndexStoreClientImplementation(string name, st
|
||||
/// GetDbConnection. The connections of the context share one cache, and a shared cache locks
|
||||
/// whole tables: reading the whole database for the copy would hold back every writer until the
|
||||
/// copy is done. Without pooling, nothing keeps the copy open afterward, so the backup can
|
||||
/// delete it on every OS.
|
||||
/// delete it on every OS.<br/><br/>
|
||||
///
|
||||
/// SQLite runs its async methods synchronously, and copying and checking a large index takes a
|
||||
/// while. The copy therefore runs on a thread of its own, so that it never holds up its caller.
|
||||
/// </remarks>
|
||||
public override async Task<string> BackupToDirectoryAsync(string targetDirectory, CancellationToken token)
|
||||
public override Task<string> BackupToDirectoryAsync(string targetDirectory, CancellationToken token) => Task.Run(() => this.CopyAndCheckAsync(targetDirectory, token), token);
|
||||
|
||||
private async Task<string> CopyAndCheckAsync(string targetDirectory, CancellationToken token)
|
||||
{
|
||||
Directory.CreateDirectory(targetDirectory);
|
||||
var targetPath = Path.Join(targetDirectory, DATABASE_FILENAME);
|
||||
|
||||
Reference in new issue
Block a user