The results of is_dir() are cached

So before calling is_dir() for the second time, clearstatcache of the dir