moved the getAttributes call into the if statement so it only gets called when we know we're about to add the file, after all the necessary checks have happened