Persist file categories on the index and classify archives and unknown types during idle maintenance.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-28 11:37:29 +02:00
parent b33a78dbbe
commit 222b5d9969
42 changed files with 1719 additions and 80 deletions

View File

@@ -44,4 +44,37 @@ public class SearchServiceTests
Assert.Contains(both, e => e.Name == "Folder");
Assert.Contains(both, e => e.Name == "notes.txt");
}
[Fact]
public async Task Category_hint_and_filter()
{
var db = Path.Combine(Path.GetTempPath(), "ew-search", Guid.NewGuid().ToString("N"), "index.db");
await using var store = new SqliteIndexStore(db, NullLogger<SqliteIndexStore>.Instance);
await store.OpenAsync();
var source = new Source { StableKey = "k", DisplayName = "d", Kind = SourceKind.NtfsLocal, LastRootPath = @"C:\d", Status = SourceStatus.Online };
source.Id = await store.Sources.UpsertAsync(source);
var root = new IndexEntry { SourceId = source.Id, Name = "d", NameNorm = "d", IsDirectory = true, PathRel = "", LastSeenUtc = DateTimeOffset.UtcNow };
root.Id = await store.Entries.UpsertAsync(root);
await store.Entries.UpsertAsync(new IndexEntry
{
SourceId = source.Id, ParentId = root.Id, Name = "clip.mkv", NameNorm = "clip.mkv", Extension = "mkv",
PathRel = "clip.mkv", LastSeenUtc = DateTimeOffset.UtcNow
});
await store.Entries.UpsertAsync(new IndexEntry
{
SourceId = source.Id, ParentId = root.Id, Name = "notes.pdf", NameNorm = "notes.pdf", Extension = "pdf",
PathRel = "notes.pdf", LastSeenUtc = DateTimeOffset.UtcNow
});
var search = new SearchService(store);
var hinted = await search.SearchAsync(new SearchQuery { Text = "category:video", SourceIds = [source.Id] });
Assert.Single(hinted);
Assert.Equal("clip.mkv", hinted[0].Name);
var filtered = await search.SearchAsync(new SearchQuery { Category = FileCategory.Documents, SourceIds = [source.Id] });
Assert.Single(filtered);
Assert.Equal("notes.pdf", filtered[0].Name);
var split = SearchService.SplitCategoryHint("vacation category:photos");
Assert.Equal("vacation", split.Name);
Assert.Equal(FileCategory.Photos, split.Category);
}
}