YunoHost-Apps / codimd_ynh

CodiMD package for YunoHost
https://hackmd.io/
GNU General Public License v3.0
11 stars 12 forks source link

config.json is overwritten by update #46

Closed fflorent closed 3 years ago

fflorent commented 3 years ago

Describe the bug

When updating the application, /var/www/codimd/config.json is overwritten, despite the README file which invites to tweak it.

Versions

To Reproduce

  1. Get an old version of Codimd.
  2. Add in /var/www/codimd/config.json and in the "production"section the following line:"tooBusyLag": 10000,`
  3. Restart the service in order to see the change
  4. Upgrade Codimd
  5. Check the content of the /var/www/codimd/config.json file

Expected behavior You should see the "tooBusyLag": 10000, line in the above file

Actual behavior The line has disappeared.

lapineige commented 3 years ago

I don't really know how other Yunohost package manage that (ping @YunoHost-Apps/apps-group) appart from making a backup and letting you manually transfer the changes if you want to (I do that for Pixelfed, it's painful, but at least my changes are not lost).

fflorent commented 3 years ago

As a workaround to this issue, you may create a empty file with env variables (maybe with just a comment to explain how to fill it) and source it when running codimd. So the user can only tweak the file with env variable and the app maintainer may tweak the config.json file at his/her convenience.

If I quote this page:

 Environment variables take precedence over configurations from the config files. They generally start with CMD_ for our own options, but we also list node-specific options you can configure this way.

ericgaspar commented 3 years ago

@fflorent This upgraded version of CodiMD allows installation in a sub-folder, therefore the config.json file has a new $path argument hence the choice to overwrite the previous config.json file. Not ideal I guess...

fflorent commented 3 years ago

Useful link for sourcing an environment file in a systemd service:

https://fedoraproject.org/wiki/Packaging:Systemd#EnvironmentFiles_and_support_for_.2Fetc.2Fsysconfig_files

yalh76 commented 3 years ago

Describe the bug

When updating the application, /var/www/codimd/config.json is overwritten, despite the README file which invites to tweak it.

Yes it's a normal behavior, it's why during upgrade, there is : https://github.com/YunoHost-Apps/codimd_ynh/blob/58e85a9edda5b6a90dfb06b25a5534f1f07ff648/scripts/upgrade#L140

ynh_backup_if_checksum_is_different keep a copy of the the config file to let you tweak again :)