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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user