Use clean/require in file._check_directory state, Fix #4777