static async Task Index(Queue <ChangeInfo> changeQueue, IDbAdapter dbAdapter) { while (true) { if (changeQueue.Count > 0) { var change = changeQueue.Dequeue(); System.Console.WriteLine(change.EventType + " " + change.Path); switch (change.EventType) { case "Renamed": await dbAdapter.UpdateIndexes(IndexUtils.CreateUpdateIndex(change.Path.ToLower(), change.NewPath.ToLower())); break; case "Created": var newIdx = new Index { Name = Path.GetFileNameWithoutExtension(change.Path), Extention = Path.GetExtension(change.Path), Folder = Path.GetDirectoryName(change.Path), SearchKey = change.Path, }; dbAdapter.SetIndexes(new List <Index> { newIdx }, false); break; case "Deleted": await dbAdapter.UpdateIndexes(IndexUtils.CreateUpdateIndex(change.Path.ToLower(), null)); break; default: break; } } await Task.Delay(100); } }
public void Set(IEnumerable <Index> newIndexes, bool overrideAll) { _dbAdapter.SetIndexes(newIndexes, overrideAll); }