Make sure the base directory exists before insert