Skip to content

Always write the default config if the primary config file is missing#3117

Merged
johnnovak merged 1 commit intomainfrom
jn/write-default-config-fix
Nov 14, 2023
Merged

Always write the default config if the primary config file is missing#3117
johnnovak merged 1 commit intomainfrom
jn/write-default-config-fix

Conversation

@johnnovak
Copy link
Copy Markdown
Member

@johnnovak johnnovak commented Nov 14, 2023

Description

Fixes #3116

Prior to this change, if the primary config file was missing, it was created, but instead of the defaults, the current config settings were written. This included the local dosbox.conf if it existed and any extra configs loaded with the --conf CLI option on top of the actual defaults.

This change ensures that if we create the primary config on startup, it always contains the defaults and nothing else.

Manual testing

If the primary config does NOT exist in the user folder

Test 1

  • Started Staging in a directory that has a local config that set cycles to 6666.
  • Confirmed the primary config was created with the defaults
  • Confirmed "Created primary config file" comes before "Loaded local config file 'dosbox.conf'" in the logs.

Test 2

  • Started Staging in the same directory with --nolocalconf --conf dosbox.conf.
  • Confirmed the primary config was created with the defaults.
  • Confirmed "Created primary config file" comes before "Loaded custom config file 'dosbox.conf'" in the logs.

Test 3

  • Started Staging with --machine hercules --set cycles=6666.
  • Confirmed the primary config was created with the defaults.

Test 4

  • Confirmed the primary config is not created when the --noprimaryconf option is present, regardless of the presence of the local config or any other CLI options.

Test 5

  • Confirmed the primary config is not created when launching Staging in portable mode (dosbox-staging.conf exists in the executable directory).

If the primary config DOES exist in the user folder

Confirmed that it never gets recreated or overwritten in any of the above test cases.

Checklist

Please tick the items as you have addressed them. Don't remove items; leave the ones that are not applicable unchecked.

I have:

  • followed the project's contributing guidelines and code of conduct.
  • performed a self-review of my code.
  • commented on the particularly hard-to-understand areas of my code.
  • split my work into well-defined, bisectable commits, and I named my commits well.
  • applied the appropriate labels (bug, enhancement, refactoring, documentation, etc.)
  • checked that all my commits can be built.
  • confirmed that my code does not cause performance regressions (e.g., by running the Quake benchmark).
  • added unit tests where applicable to prove the correctness of my code and to avoid future regressions.
  • made corresponding changes to the documentation or the website according to the documentation guidelines.
  • locally verified my website or documentation changes.

@johnnovak johnnovak force-pushed the jn/write-default-config-fix branch from 040f58a to bf01bab Compare November 14, 2023 02:30
@johnnovak johnnovak self-assigned this Nov 14, 2023
@johnnovak johnnovak added bug Something isn't working enhancement New feature or enhancement of existing features and removed enhancement New feature or enhancement of existing features labels Nov 14, 2023
@johnnovak johnnovak marked this pull request as ready for review November 14, 2023 02:31
Prior to this change, if the primary config file was missing, it was
created, but instead of the defaults, the current config settings were
written. This included the local `dosbox.conf` if it existed and any
extra configs loaded with the `--conf` CLI option on top of the actual
defaults.

This change ensures that whenever we create the primary config on
startup, it always contains the defaults and nothing else.
@johnnovak johnnovak requested a review from kcgen November 14, 2023 02:32
@johnnovak johnnovak force-pushed the jn/write-default-config-fix branch from bf01bab to e5f2b5e Compare November 14, 2023 02:32
@kcgen
Copy link
Copy Markdown
Member

kcgen commented Nov 14, 2023

Test cases nailed all the scenarios I could think of. Nice fix @johnnovak, and great catch by LiPillON 👍

@johnnovak
Copy link
Copy Markdown
Member Author

Thanks for the review @kcgen , can you please approve it then?

@kcgen
Copy link
Copy Markdown
Member

kcgen commented Nov 14, 2023

Thanks for the review @kcgen , can you please approve it then?

Was trying github's app on my phone.. but couldn't figure out how to review/approve. Back on the website now - and approved :-)

@johnnovak
Copy link
Copy Markdown
Member Author

Thanks for the review @kcgen , can you please approve it then?

Was trying github's app on my phone.. but couldn't figure out how to review/approve. Back on the website now - and approved :-)

Thanks man 😄 I found it on my phone once, I think it's under "Files changed" 😄

@johnnovak johnnovak merged commit 0a25e14 into main Nov 14, 2023
@kcgen kcgen deleted the jn/write-default-config-fix branch November 16, 2023 18:46
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

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

"%LOCALAPPDATA%\dosbox\dosbox-staging.conf" created and used even when the -conf parameter is being used

2 participants