Youda008 / DoomRunner

Preset-oriented graphical launcher of various ported Doom engines (an alternative to ZDL)
GNU General Public License v3.0
204 stars 13 forks source link

options.json gets rewritten for no reason and gets wiped on PC crash #110

Closed GrayFace closed 11 months ago

GrayFace commented 12 months ago

DoomRunner seems to constantly rewrite options.json while running. This is horrible in itself, and also leads to the file being filled with zeroes if PC crashes.

Youda008 commented 12 months ago

Well, it doesn't. It is first written to a new file and then it replaces the old file, see https://github.com/Youda008/DoomRunner/blob/master/Sources/Utils/FileSystemUtils.cpp#L69C1-L69C1

This has been reported many times already, but i have no idea what's going on and how to fix it. I'm very sorry for these issues, but I'm really helpless until somebody tells me how exactly it happens.

GrayFace commented 12 months ago

It does! I've just checked - it saves options.json every minute! It does it while I'm not changing anything.

Youda008 commented 12 months ago

Yes, once every 60 seconds. If i was saving it only on close, and your OS crashed before you close it, you would lose all changes. Do you have any better idea?

GrayFace commented 12 months ago

Saving only after changes. Simplest fix would be to compare the binary array to what has been read or saved last time.

Youda008 commented 12 months ago

Alright, got some tips on programing forums, will give it another try in the next version.

Youda008 commented 11 months ago

I have reduced the frequency of writing to file, by making it write the content only when something has changed. Hopefully that will solve your issue.