Question

I have a task to implement service with behavior like this one. My question is:

How Indexing Service remember what files was already indexed and what no, what files changed and need to reindex them?

Also, I can stop this service and then start it after a few days, it continues to work. Does it have its own database with information about files?

Thank you

Was it helpful?

Solution

Usually the indexing-service stays in the background using WaitForSingleObject / WaitForMultipleObjects on Handles created by calls to FindFirstChangeNotification. If you want to support that the indexing service can be shut down (or be used for an already existent directory) you should definitely store the timestamp of your last index run on every file. You can compare this to the LastWriteTime of the given file.

EDIT: you should use ReadDirectoryChangesW and another thread which asynchronously indexes the files to be sure to not miss any changes. You can either spawn new threads for every file to index(expensive) or use a job queue and a fixed amount of worker threads(1 or 2 preferably)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top