Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

settings.json and everything else overwritten without permission mysteriously #208

Open
acidhorse1972 opened this issue May 18, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@acidhorse1972
Copy link

acidhorse1972 commented May 18, 2024

So here's what happened:
I click on the icon shortcut for supercell-wx on my taskbar.
It loads up but the popup Introduction dialog for getting started shows up.
Nothing has been touched altered or anything.
Screenshot 2024-05-17 213055

My placefile definitions are gone and settings.json was overwritten by supercell-wx for some mysterious reason.
The MapTiler API key is gone too.

@acidhorse1972 acidhorse1972 added the bug Something isn't working label May 18, 2024
@acidhorse1972 acidhorse1972 changed the title settings.json and everything else overwritten with new fresh copies settings.json and everything else overwritten without permission mysteriously May 18, 2024
@dpaulat
Copy link
Owner

dpaulat commented May 18, 2024

Did anything precede this occurring (manual edit, changing settings to a specific value, deleting or renaming a file)? The files are stored in %AppData%\Supercell Wx.

@acidhorse1972
Copy link
Author

Did anything precede this occurring (manual edit, changing settings to a specific value, deleting or renaming a file)? The files are stored in %AppData%\Supercell Wx.

Nope nothing.

@acidhorse1972
Copy link
Author

acidhorse1972 commented May 19, 2024

Is the program set to overwrite anything if any kind of conditions are met?
It should prompt to overwrite anything. Popup Dialog "Do you want to overwrite blah blah blah" "OK" "Cancel" "Yes" "No" "Abort" "Plan D"
A database file would probably work better. SQLite or .DB files "Select * from Placefiles where etc etc" "UPDATE etc"

@dpaulat
Copy link
Owner

dpaulat commented May 19, 2024

I chose JSON over a binary format like a SQLite database, because it's human readable.

The only time the application should overwrite the JSON files is if the files have syntax errors (e.g., missing/extra commas). Invalid or missing values are corrected, and should not impact the rest of the file. I do not expect outside of hand-editing that this should occur. It seems I may have missed a case. I'm thinking it'd be good that if there is a syntax error, I at least create a backup of the file prior to saving updated settings to give the opportunity for a correction.

If you open an older version of Supercell Wx, newer settings values could be removed/reset.

I'm trying to think of other scenarios, some hypothetical:

  • File open in a text editor that prevents reading by another program
  • File system error
  • Out of disk space
  • Running as a different user
  • User folder changed (%AppData%)

Multiple instances of Supercell Wx being open should not impact this significantly, as they both use the same set of configuration files. They only write on settings change or exit (or startup if there is something invalid), not without user interaction. Ultimately though, one of these instances could overwrite settings made by another instance.

It's strange that both settings and placefiles were nuked, as these are stored in separate files.

@acidhorse1972
Copy link
Author

I chose JSON over a binary format like a SQLite database, because it's human readable.

The only time the application should overwrite the JSON files is if the files have syntax errors (e.g., missing/extra commas). Invalid or missing values are corrected, and should not impact the rest of the file. I do not expect outside of hand-editing that this should occur. It seems I may have missed a case. I'm thinking it'd be good that if there is a syntax error, I at least create a backup of the file prior to saving updated settings to give the opportunity for a correction.

If you open an older version of Supercell Wx, newer settings values could be removed/reset.

I'm trying to think of other scenarios, all hypothetical:

* File open in a text editor that prevents reading by another program

* File system error

* Out of disk space

Multiple instances of Supercell Wx being open should not impact this significantly, as they both use the same set of configuration files. They only write on settings change or exit (or startup if there is something invalid), not without user interaction. Ultimately though, one of these instances could overwrite settings made by another instance.

It's strange that both settings and placefiles were nuked, as these are stored in separate files.

One way to make sure that a user knows that something fishy is going on is to ask whether they want to allow it to overwrite the existing file or notify the user that the file doesn't exist and then ask if the user wants to create a new settings file. An empty placefile list index file should pre-exist before any placefile references are ever created so that if the settings and the placefile list file doesn't exist when it should then flags can be thrown and errors declared and logs checked.

@dpaulat
Copy link
Owner

dpaulat commented May 19, 2024

I edited and added two more potential items with the previous post after you started to quote:

  • Running as a different user
  • User folder changed (%AppData%)

With the settings and placefile list being stored in the user directory rather than the application directory, there has to be an initial "create if it doesn't exist", if this is the first time a user is running, or upgrades to a version that supports the JSON file. That's not an error condition.

I did start to add the setup dialog if certain conditions were not met in the settings file.

Did you happen to note if there was anything in the terminal that displayed? I have a handful of warnings and errors with the following prefixes:

  • [scwx::qt::util::json]
  • [scwx::qt::manager::settings_manager]

@acidhorse1972
Copy link
Author

I edited and added two more potential items with the previous post after you started to quote:

* Running as a different user

* User folder changed (%AppData%)

With the settings and placefile list being stored in the user directory rather than the application directory, there has to be an initial "create if it doesn't exist", if this is the first time a user is running, or upgrades to a version that supports the JSON file. That's not an error condition.

I did start to add the setup dialog if certain conditions were not met in the settings file.

Did you happen to note if there was anything in the terminal that displayed? I have a handful of warnings and errors with the following prefixes:

* [scwx::qt::util::json]

* [scwx::qt::manager::settings_manager]

Nope I didn't realize that I needed to check that. There needs to be a flag somewhere that determines when the "First Run" occurred. So that it can compare time and dates. If the settings is missing and there is something that has the original first run date and time and dates don't match then it should log everything to an error.log file. and run Notepad.exe on it.

@acidhorse1972
Copy link
Author

might be a good idea to set read-only attributes on those files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants