I've encountered weird regression, introduced by D18830: Handle folders matching substrings of included/excluded folders correctly. Here is the description:
- Since some time, config->includeFolders() contains folders with trailing slashes.
- First entry that QDirIterator::path() returns matches exactly its argument, i.e. if we feed it with path with trailing slash, it will return exactly it. All the other paths don't have trailing slashes though.
- Because of that, inside UnindexedFileIndexer::run(), when we check whether path has changed, we perform comparison it.filePath() == tr.documentUrl(id), and it fails becaue documentUrl() always returns path without trailing slash.
- So we call DocumentUrlDB::replace(), which removes old entry and calls DocumentUrlDB::put().
- Finally, for some reason, IdTreeDB don't want to work with paths with trailing slashes, so it gets silently ignored.
So in the end of the day we get entry for includeFolder removed from DB. Which corrupts IdTreeDB --- it can no longer resolve paths.
The simplest solution proposed here is to make sure our DirIterator always returns paths without trailing slash, including first call.
BUG: 409257