You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.
Currently, NML nukes the existing mod configuration file as it writes a new one. If something goes wrong, this can result in an empty or partially written file. Relevant code here.
If this fails it's a pretty bad experience for the user, as NML will have all sorts of errors trying to load the broken configs, so not only has the user lost their configuration, they've also got to go manually delete the broken files.
This configuration save process could be made much more robust by writing to an intermediate file and then only on success copying that over the real config file. For example, using a temporary MyMod.tmp.json file:
Delete MyMod.tmp.json if it exists
Write new config to MyMod.tmp.json
Optionally, verify that MyMod.tmp.json is contains valid JSON
Delete MyMod.json
Move MyMod.tmp.json to MyMod.json
There may be other ways of doing this—I've just suggested one possibility. For example, if C# has an API somewhere that can atomically replace an existing file (like a unix-style mv) that'd be even better.
The text was updated successfully, but these errors were encountered:
Currently, NML nukes the existing mod configuration file as it writes a new one. If something goes wrong, this can result in an empty or partially written file. Relevant code here.
If this fails it's a pretty bad experience for the user, as NML will have all sorts of errors trying to load the broken configs, so not only has the user lost their configuration, they've also got to go manually delete the broken files.
This configuration save process could be made much more robust by writing to an intermediate file and then only on success copying that over the real config file. For example, using a temporary
MyMod.tmp.json
file:MyMod.tmp.json
if it existsMyMod.tmp.json
MyMod.tmp.json
is contains valid JSONMyMod.json
MyMod.tmp.json
toMyMod.json
There may be other ways of doing this—I've just suggested one possibility. For example, if C# has an API somewhere that can atomically replace an existing file (like a unix-style
mv
) that'd be even better.The text was updated successfully, but these errors were encountered: