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