COOK-2072: check that the directory is not nil before attempting to create it