fix the bug in missing the mode param of ensureDir