adamrehn / ue4cli

Command-line interface for Unreal Engine 4
https://docs.adamrehn.com/ue4cli/
MIT License
249 stars 45 forks source link

'ue4 setroot' saves the root even when specified directory is NOT valid #68

Open sleeptightAnsiC opened 3 months ago

sleeptightAnsiC commented 3 months ago
$ ue4 setroot jndksfjnaskldjfnksda
Set engine root path override: /home/kornel/Projects/ue4cli/jndksfjnaskldjfnksda
Using user-specified engine root: /home/kornel/Projects/ue4cli/jndksfjnaskldjfnksda
Warning: the specified directory does not appear to contain a valid version of the Unreal Engine.
# return code 0

$ ue4 root
Using user-specified engine root: /home/kornel/Projects/ue4cli/jndksfjnaskldjfnksda
/home/kornel/Projects/ue4cli/jndksfjnaskldjfnksda
# return code 0

This should not happen. Setting root override to a non-valid Engine directory should fail. Currently it always saves the override no matter what, and only prints warning.

In https://github.com/adamrehn/ue4cli/pull/65 I already changed warning to error by throwing UnrealManagerException. Now I need to also prevent the override from being saved.

This is a bit tricky to fix as currently we save the override first and then validate it afterwards:

https://github.com/adamrehn/ue4cli/blob/fed71c1af4cffe3fed9358b08430068ad9454b77/ue4cli/UnrealManagerBase.py#L39-L54