[indexcleaner] Avoid removing included folders below excluded ones
Summary:
This fixes a regression introduced with commit e58804bf9eb8
("React to config updates inside indexer").
The recursion should stop when it reaches an explicitly included folder,
thus pass shouldDelete also into the iteration for excluded folders.
The current unconditional removal causes recurrent indexing of included
subtrees on each login.
Do a depth first walk, and after returning check if there are any
children left. Only delete the folder if it is empty. Otherwise, the
directory tree structure has dangling subtrees.
Test Plan:
configure an includeFolder below an excludeFolder
start balooctl monitor
restart baloo_file
files below the includeFolder should not be needed to be reindexed
Reviewers: Baloo, Frameworks, ngraham, astippich, poboiko
Reviewed By: Baloo, ngraham
Subscribers: kde-frameworks-devel
Tags: Frameworks, Baloo
Differential Revision: https://phabricator.kde.org/D20299