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

Check that config is valid before saving #2152

Merged
merged 1 commit into from
Mar 24, 2022
Merged

Conversation

Nutomic
Copy link
Member

@Nutomic Nutomic commented Mar 24, 2022

It turns out that you can currently set a config that is completely invalid (eg wrong braces), and Lemmy will happily save it, reload the config and then stop working. This adds a simple check to make sure that the config can be parsed before saving.

There are also some other problems with updating the config like this:

  • If any error happens, it is simply reported as couldnt_update_site. Would be good if this could be more specific, eg indicating that the given config is invalid (and in which place), or that the file is not writable.
  • It would be nice if we could pretty print the new config, but thats not supported by deser-hjson crate.
  • Some config changes (e.g. enabling federation) require a restart of Lemmy. I tried to do that by caling System::exit() in save_config_file(), but it didnt seem to work. Would be good to mention in lemmy-ui that a restart is necessary.

@Nutomic Nutomic requested a review from dessalines as a code owner March 24, 2022 12:41
@dessalines dessalines enabled auto-merge (squash) March 24, 2022 15:53
@dessalines dessalines merged commit 83e9961 into main Mar 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants