Repair broken parent link in the scanner

Make sure the `parent` row is set correctly in the database to prevent ghost files in the cache.

Possible fix for #8118 

cc @PVince81 
Please add a comment like "Check whether parent exists in cache, if not: repair it. Could happen when entries are missing the cache"