Redmine#6331: Skip non-empty directories silently when recursively deleting

The last commit fixes Redmine#6331, by skipping non-empty directories silently when recursively deleting. The rest are only making the code easier to digest.