Fix a bug where an error change any permissions would cause the operation to fail and other files to not be changed