Cut over the window to Explorer.Host.exe so only the host writes the index.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-24 17:39:13 +02:00
parent 7c23bc2474
commit 48d03f794f
26 changed files with 774 additions and 59 deletions

View File

@@ -451,4 +451,24 @@ public class IndexStoreLockTests
Assert.Equal(IndexStoreLock.MutexNameFor(path), IndexStoreLock.MutexNameFor(path));
Assert.StartsWith(@"Local\ExplorerWorkbench-Index-", IndexStoreLock.MutexNameFor(path));
}
[Fact]
public async Task Read_only_store_opens_while_writer_holds_the_mutex()
{
var path = Path.Combine(Path.GetTempPath(), "ew-tests", Guid.NewGuid().ToString("N"), "index.db");
await using var writer = new SqliteIndexStore(path, NullLogger<SqliteIndexStore>.Instance);
await writer.OpenAsync();
await writer.AddSourceAsync(@"C:\data");
await using var reader = new SqliteIndexStore(path, NullLogger<SqliteIndexStore>.Instance, readOnly: true);
await reader.OpenAsync();
Assert.False(reader.CanWrite);
var sources = await reader.Sources.GetAllAsync();
Assert.Single(sources);
Assert.Equal(@"C:\data", sources[0].LastRootPath);
var write = await Assert.ThrowsAsync<InvalidOperationException>(
() => reader.RunWriteAsync(_ => Task.CompletedTask));
Assert.Contains("read-only", write.Message, StringComparison.OrdinalIgnoreCase);
}
}