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

Preserve Comments and Formatting in Configuration Files After Web Interface Modifications #166

Open
jojo141185 opened this issue Feb 1, 2025 · 5 comments
Labels
enhancement New feature or request

Comments

@jojo141185
Copy link
Contributor

Is your feature request related to a problem? Please describe.
After making changes to the configuration via the web interface and saving it, all existing comments and formatting (e.g., CR) are removed, leading to the loss of important comments and structure in the configuration file.

Describe the solution you'd like
The goal is to preserve the existing comments and ensure that the formatting/structure of the configuration file remains intact. One potential solution is to switch to TOML as the configuration format, which better supports the preservation of comments and formatting. A library like toml_edit can be used to manipulate TOML files while retaining comments and formatting.

Alternatively, if YAML continues to be used, it would be necessary to explore a more flexible library that allows comments and formatting preservation during updates, similar to how toml_edit works for TOML files.

Describe alternatives you've considered

  • Continuing to use YAML and investigating libraries that can preserve comments and formatting.
  • Refactoring the configuration management to switch to TOML, which offers better support for this feature via toml_edit.

Additional context
Switching to TOML, along with a library like toml_edit, would likely resolve this issue by ensuring that valuable information like comments or formatting is not lost when configuration changes are applied through the web interface. If YAML is preferred, further investigation into suitable libraries for comment preservation would be necessary.

@euzu
Copy link
Owner

euzu commented Feb 1, 2025

@jojo141185 serde_yaml wont support comments. So it would not possible to keep them. I looked for other libs and it seems it is not possible to guarantee that comments would be available when serialized.

You are right about toml, it seems the crate toml_edit can preserve comments.

I personally dont like toml syntax, but we could make it configurable to decide what the user prefers.
I personally will stick with yaml because i find it more readable and structured.

@jojo141185
Copy link
Contributor Author

@euzu While testing the WebUI to change some configs today, all my comments and the overall structure of my rather complex configuration files were completely lost. This was a bit frustrating and the reason I thought it might be worth discussing the topic and submitting a feature request or at least keeping an eye on the problem.

But you're absolutely right that it's not strictly necessary to make this change, and introducing two different configuration formats could potentially confuse many users. I would not recommend that. Moreover, it would generate a lot of work that could be better used for useful new features.

For me, the format itself isn't as critical. However, I did come across an interesting article a while ago, which pointed out some pitfalls with YAML that should be kept in mind . In comparison, TOML has fewer such pitfalls, though ultimately, it's a matter of personal preference based on what one is accustomed to and prefers to use.

We could certainly keep this in mind as a potential improvement for the future, and if a more optimized YAML library with features comparable to toml_edit becomes available, we can reconsider it.

@euzu
Copy link
Owner

euzu commented Feb 1, 2025

normally there is a backup folder where the previous version of the config is stored.

Image

@jojo141185
Copy link
Contributor Author

jojo141185 commented Feb 1, 2025

Good point, I didn't look for configs backup in data folder 👍
But I even configured it there myself via backup_dir ;-)

@euzu euzu added the enhancement New feature or request label Feb 4, 2025
@aniel300
Copy link

@euzu does this relates to what we discussed about the format the webui uses vs the one that is in the wiki which i like more as it looks cleaner and more space efficient?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants