Temporary directory handling had a logical error, assuming the
"session" temporary directory was owned and created by Blender
and could be recursively removed on exit.
However, it's possible creating the session sub-directory fails,
in that case the temporary directory was used for the "session".
This meant setting `C:\` as the temporary directory in the preferences
would attempt to recursively remove `C:\` on exit.
Resolve with the following changes:
- Only perform a recursive removal on the temporary directory
if a session sub-directory was created.
- If the creating the user-preferences temporary "session" sub-directory
fails fall back to the systems temporary directory and try to
create the "session" directory there.
Previously this was only done if the preference path didn't exist.
The preferences path was still used if it existed but couldn't be
written to.
Include a test to ensure this is working as expected.
Ref !144042