Show folder names immediately and refresh stale index sizes without walking the whole drive.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-26 11:21:20 +02:00
parent 6fc7506eb7
commit e2916aef9c
88 changed files with 5373 additions and 544 deletions

View File

@@ -263,6 +263,70 @@ public class ScannerTests
}
}
[Fact]
public async Task Verify_reconcile_updates_child_folder_size_after_uninstall()
{
var root = CreateTree();
var unity = Path.Combine(root, "Unity");
var editor = Path.Combine(unity, "Editor");
Directory.CreateDirectory(editor);
await File.WriteAllTextAsync(Path.Combine(editor, "big.bin"), new string('x', 10_000));
await File.WriteAllTextAsync(Path.Combine(unity, "leftover.txt"), "ok");
try
{
await using var store = await OpenStore();
var source = await AddSource(store, root);
var scanner = new FilesystemScanner(store, new IoEnumerator(), new StorageProviderRegistry([], NullLogger<StorageProviderRegistry>.Instance), NullLogger<FilesystemScanner>.Instance);
await scanner.ScanAsync(source, ScanKind.Full, null, null, CancellationToken.None);
var before = await store.Entries.GetByPathAsync(source.Id, "Unity");
Assert.True(before!.AggregateSize >= 10_000);
Directory.Delete(editor, recursive: true);
var reconciler = new FolderReconciler(store, new IoEnumerator(), new StorageProviderRegistry([], NullLogger<StorageProviderRegistry>.Instance));
await reconciler.ReconcileAsync(source, "", CancellationToken.None);
var shallow = await store.Entries.GetByPathAsync(source.Id, "Unity");
Assert.True(shallow!.AggregateSize >= 10_000);
await reconciler.ReconcileAsync(source, "", CancellationToken.None, verifyChildren: true);
var verified = await store.Entries.GetByPathAsync(source.Id, "Unity");
Assert.True(verified!.AggregateSize < 1_000);
var editorEntry = await store.Entries.GetByPathAsync(source.Id, @"Unity\Editor");
Assert.Equal(EntryStatus.Deleted, editorEntry!.Status);
}
finally
{
TryDelete(root);
}
}
[Fact]
public async Task Verify_from_root_finds_nested_emptied_folder()
{
var root = CreateTree();
var programFiles = Path.Combine(root, "Program Files");
var unity = Path.Combine(programFiles, "Unity");
var editor = Path.Combine(unity, "Editor");
Directory.CreateDirectory(editor);
await File.WriteAllTextAsync(Path.Combine(editor, "big.bin"), new string('x', 10_000));
await File.WriteAllTextAsync(Path.Combine(unity, "leftover.txt"), "ok");
try
{
await using var store = await OpenStore();
var source = await AddSource(store, root);
var scanner = new FilesystemScanner(store, new IoEnumerator(), new StorageProviderRegistry([], NullLogger<StorageProviderRegistry>.Instance), NullLogger<FilesystemScanner>.Instance);
await scanner.ScanAsync(source, ScanKind.Full, null, null, CancellationToken.None);
Directory.Delete(editor, recursive: true);
var reconciler = new FolderReconciler(store, new IoEnumerator(), new StorageProviderRegistry([], NullLogger<StorageProviderRegistry>.Instance));
await reconciler.ReconcileAsync(source, "", CancellationToken.None, verifyChildren: true);
var verified = await store.Entries.GetByPathAsync(source.Id, @"Program Files\Unity");
Assert.True(verified!.AggregateSize < 1_000);
}
finally
{
TryDelete(root);
}
}
[Fact]
public async Task Folder_reconcile_tombs_removed_file()
{