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:
@@ -37,6 +37,47 @@ public class BrowseServiceTests
|
||||
Assert.Contains(listing.Items, i => i.FullPath == LocationRoots.RecycleBin);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Home_lists_existing_known_folders()
|
||||
{
|
||||
var (browse, store) = await CreateAsync(
|
||||
@"C:\",
|
||||
"C:",
|
||||
knownFolders: new StubKnownFolders(
|
||||
[
|
||||
new KnownUserFolder("Documents", @"C:\Users\Test\Documents", "d"),
|
||||
new KnownUserFolder("Downloads", @"C:\Users\Test\Downloads", "l")
|
||||
]));
|
||||
var listing = browse.ListHome();
|
||||
Assert.Equal(LocationRoots.Home, listing.Path);
|
||||
Assert.Equal(2, listing.Items.Count);
|
||||
Assert.Equal("Documents", listing.Items[0].DisplayName);
|
||||
Assert.Equal(@"C:\Users\Test\Documents", listing.Items[0].FullPath);
|
||||
Assert.True(listing.Items[0].IsDirectory);
|
||||
await store.DisposeAsync();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Favorites_lists_pinned_folders_including_offline()
|
||||
{
|
||||
var missing = Path.Combine(Path.GetTempPath(), "ew-fav-missing", Guid.NewGuid().ToString("N"));
|
||||
var (browse, store) = await CreateAsync(
|
||||
@"C:\",
|
||||
"C:",
|
||||
configurePrefs: prefs => prefs.Save(UiPreferences.Default with
|
||||
{
|
||||
FavoriteFolders = [@"D:\Photos", missing]
|
||||
}));
|
||||
var listing = browse.ListFavorites();
|
||||
Assert.Equal(LocationRoots.Favorites, listing.Path);
|
||||
Assert.Equal(2, listing.Items.Count);
|
||||
Assert.Equal(@"D:\Photos", listing.Items[0].FullPath);
|
||||
Assert.Equal("Photos", listing.Items[0].Name);
|
||||
Assert.Equal(missing, listing.Items[1].FullPath);
|
||||
Assert.Contains("(Offline)", listing.Items[1].DisplayName);
|
||||
await store.DisposeAsync();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task This_pc_lists_untracked_network_drives_as_importable()
|
||||
{
|
||||
@@ -211,7 +252,8 @@ public class BrowseServiceTests
|
||||
string display,
|
||||
IRecycleBinCatalog? recycle = null,
|
||||
IFileSystemEnumerator? enumerator = null,
|
||||
Action<UiPreferencesStore>? configurePrefs = null)
|
||||
Action<UiPreferencesStore>? configurePrefs = null,
|
||||
IKnownUserFolderCatalog? knownFolders = null)
|
||||
{
|
||||
var db = Path.Combine(Path.GetTempPath(), "ew-browse", Guid.NewGuid().ToString("N"), "index.db");
|
||||
var store = new SqliteIndexStore(db, NullLogger<SqliteIndexStore>.Instance);
|
||||
@@ -244,11 +286,17 @@ public class BrowseServiceTests
|
||||
new StorageProviderRegistry([], NullLogger<StorageProviderRegistry>.Instance),
|
||||
new CloudPlaceStore(env),
|
||||
prefs,
|
||||
recycle: recycle);
|
||||
recycle: recycle,
|
||||
knownFolders: knownFolders);
|
||||
return (browse, store);
|
||||
}
|
||||
}
|
||||
|
||||
file sealed class StubKnownFolders(IReadOnlyList<KnownUserFolder> folders) : IKnownUserFolderCatalog
|
||||
{
|
||||
public IReadOnlyList<KnownUserFolder> ListExisting() => folders;
|
||||
}
|
||||
|
||||
file sealed class BrowseEnumerator : IFileSystemEnumerator
|
||||
{
|
||||
public IEnumerable<FileSystemItem> EnumerateChildren(string directoryPath)
|
||||
|
||||
Reference in New Issue
Block a user