Show the window before slow location probes and wrap git.exe for commit, diff, and merge.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-24 16:31:56 +02:00
parent a3c54bbb03
commit 9efb306979
42 changed files with 3184 additions and 77 deletions

View File

@@ -45,7 +45,7 @@ public class SourceManagerTests
CapacityBytes = 64
}
];
await mgr.RefreshOnlineStateAsync();
await mgr.RefreshOnlineStateAsync(forceRefresh: true);
var again = (await store.Sources.GetAllAsync()).Single();
Assert.Equal(key, again.StableKey);
Assert.Equal(@"G:\", again.LastRootPath);
@@ -129,7 +129,7 @@ public class SourceManagerTests
Assert.False(await mgr.ForgetDisconnectedAsync(@"Z:\"));
volumes.Online = [];
await mgr.RefreshOnlineStateAsync();
await mgr.RefreshOnlineStateAsync(forceRefresh: true);
source = (await store.Sources.GetAllAsync()).Single();
Assert.True(mgr.CanForget(source));
Assert.True(await mgr.ForgetDisconnectedAsync(@"Z:\"));
@@ -164,7 +164,7 @@ public class SourceManagerTests
await store.Sources.UpdateStatusAsync(source.Id, SourceStatus.Scanning, null);
await store.Sources.UpdateIndexedAsync(source.Id, DateTimeOffset.UtcNow, 1);
await mgr.RefreshOnlineStateAsync();
await mgr.RefreshOnlineStateAsync(forceRefresh: true);
source = (await store.Sources.GetAllAsync()).Single();
Assert.Equal(SourceStatus.Online, source.Status);
Assert.True(source.IsIndexed);
@@ -215,7 +215,7 @@ public class SourceManagerTests
Assert.Equal(guid, (await store.Sources.GetAllAsync()).Single().VolumeGuid);
volumes.Online = [];
await mgr.RefreshOnlineStateAsync();
await mgr.RefreshOnlineStateAsync(forceRefresh: true);
Assert.True(await mgr.ForgetDisconnectedAsync(@"E:\"));
Assert.Empty(await store.Sources.GetAllAsync());
@@ -231,7 +231,7 @@ public class SourceManagerTests
CapacityBytes = 64
}
];
await mgr.RefreshOnlineStateAsync();
await mgr.RefreshOnlineStateAsync(forceRefresh: true);
var restored = Assert.Single(await store.Sources.GetAllAsync());
Assert.Equal(guid, restored.VolumeGuid);
Assert.Equal(@"F:\", restored.LastRootPath);
@@ -269,12 +269,40 @@ public class SourceManagerTests
Assert.Empty(await mgr.ListUntrackedOnlineVolumesAsync());
Assert.Equal(imported.Id, (await store.Sources.GetAllAsync()).Single().Id);
}
[Fact]
public async Task Cached_refresh_skips_a_second_pass_until_forced()
{
var db = Path.Combine(Path.GetTempPath(), "ew-app", Guid.NewGuid().ToString("N"), "index.db");
await using var store = new SqliteIndexStore(db, NullLogger<SqliteIndexStore>.Instance);
var volumes = new FakeVolumes
{
Online =
[
new VolumeFingerprint { Kind = SourceKind.NtfsLocal, RootPath = @"C:\", DisplayName = "C:" }
]
};
var env = new FakeEnv(Path.GetDirectoryName(db)!);
var mgr = new SourceManager(store, volumes, env, new SystemClock(), NullLogger<SourceManager>.Instance);
await mgr.InitializeAsync();
var afterInit = volumes.EnumerateCalls;
await mgr.RefreshOnlineStateAsync();
Assert.Equal(afterInit, volumes.EnumerateCalls);
await mgr.RefreshOnlineStateAsync(forceRefresh: true);
Assert.Equal(afterInit + 1, volumes.EnumerateCalls);
}
}
file sealed class FakeVolumes : IVolumeService
{
public List<VolumeFingerprint> Online { get; set; } = [];
public IReadOnlyList<VolumeFingerprint> EnumerateOnlineVolumes() => Online;
public int EnumerateCalls;
public IReadOnlyList<VolumeFingerprint> EnumerateOnlineVolumes()
{
Interlocked.Increment(ref EnumerateCalls);
return Online;
}
public VolumeFingerprint? Probe(string path)
{
var root = Path.GetPathRoot(path)?.TrimEnd('\\');