public async Task <(IEnumerable <StoredItemInfo>, int)> ListRepositoryAsync(string repo, string passphrase, int offset, int limit, string[] tags, Func <StoredItemInfo, bool> predicate) { var ids = await driver.ListRepositoryItemIds(repo); List <StoredItemInfo> items = new(); foreach (var id in ids) { var meta = await GetItemMetadata(repo, passphrase, id); var tagMatchScore = 1; if (!tags.IsNullOrEmpty()) { var storedTags = meta.Tags ?? Array.Empty <string>(); tagMatchScore = storedTags.Intersect(tags, StringComparer.InvariantCultureIgnoreCase).Count(); } if (tagMatchScore == 0) { continue; } var info = new StoredItemInfo { ItemId = id, MimeType = meta.MimeType, Name = meta.Name, OriginalFileName = meta.OriginalFilename, Tags = meta.Tags, TagMatchScore = tagMatchScore }; if (predicate != null && !predicate(info)) { continue; } items.Add(info); } items = items.OrderByDescending(i => i.TagMatchScore).ToList(); var ret = items.Skip(offset).Take(limit); return(ret, items.Count); }