BestImageViewer / geeqie

claiming to be the best image viewer / photo collection browser
http://www.geeqie.org/
GNU General Public License v2.0
466 stars 77 forks source link

Geeqie drops unknown config options from the config file #569

Open tomaszg7 opened 6 years ago

tomaszg7 commented 6 years ago

ISSUE TYPE

SUMMARY

While switching Geeqie versions, one can easily lose parts of the config file. For example, rolling back to Geeqie 1.3 to do some testing results in losing on exiting Geeqie all the new config values that were introduced in Geeqie 1.4. I don't think it is a desired behaviour, but it is a direct consequence of the approach of regenerating config file from scratch each time Geeqie is closed.

mowgli commented 6 years ago

Do you see any way to fix your issue.

I don't think that we should support using older versions with the same config. It would mean to fix all older versions to allow the new options. That is not doable.

tomaszg7 commented 6 years ago

I don't see an easy fix. One way would be to collect all unrecognized strings from the config file and store it temporarily somewhere, adding it at the end. I don't think it is very elegant or practical.

It happens that users downgrade Geeqie for some reasons (not necesarily while doing git bisect like in my case) or just switch between versions. At some point, I managed to lose all my keywords tree in this way. I know my case was special since I was doing some testing and hacking, but still, it's not something that should happen. It also made bisecting the issue #571 harder (even though I opened this issue before I stumbled upon it).

I don't know how other programs approach this issue and I'm aware that we can't change older versions. However fixing it at some point might help in the future :)

caclark commented 6 years ago

I keep run-able copies of all Geeqie issues, and attempt to use a hack to keep multiple copies of the config file. I usually forget what I'm doing and lose my latest config file....

As far as I can tell, this style of config file is now deprecated and should be replaced by a CSS or XML type.

My first thought was to read in the entire config file, and on exit merge changes and additions, then write the whole thing out again. Not only would that be several headaches-worth of work, it's also a recipe for disaster.

tomaszg7 commented 6 years ago

Yeah, merging and correcting existing config file seems like a pain. However if Geeqie would migrate to XML, it could just read all tags, keep them in memory and write back at the end even if some of them were not supported.

tomaszg7 commented 6 years ago

Heh, you misled me a bit, @caclark ;) The config is XML type now, but the reading/writing code is hand-made. So it all probably would resolve to replacing that code by libxml2 or something similar.

caclark commented 6 years ago

Aaargh! Sorry. That was a severe case of brain-fade. I think that looking at Glade reset my brain to the happy days of VB and Microsoft .ini files.

There is also GMarkup. It looks that maybe the GMarkup parser was released at about the same time rcfile.c was converted to xml, which is maybe why the do-it-yourself option was taken.

tomaszg7 commented 6 years ago

I looked a bit at GMarkup and it seems too complicated for our simple needs. According to https://blogs.gnome.org/tthurman/2008/02/14/gmarkup/ we could look instead at e.g. Glib GKeyFile https://developer.gnome.org/glib/stable/glib-Key-value-file-parser.html. I'm not sure it could handle keywords tree, but maybe it should be moved to a separate file as it is probably only "important" part of config file (important in a sense that it could take much work to reconstruct it)

caclark commented 6 years ago

How about an option to store the previous n versions? If you find you've lost something significant, you can just roll-back to the previous version. Maybe that doesn't address the original issue here, but might help in the instance e.g. when someone has changed their keywords setup, exited, then wants to go back to the previous settings.

tomaszg7 commented 6 years ago

That may be at least a partial solution. Even keeping one previous version (geeqierc.xml.bak?) might be a helpful thing. Of course it will only help if you know about the problem, not if you realize that something went bad after a month ;)

caclark commented 6 years ago

Here is a .diff file which allows the user to save 'n' copies of the configuration file. There are some usability problems - one being that a backup is saved only if it is different to the last. But any change in window position or size also changes the file contents. So this feature isn't so useful. config_history_1.diff.gz

tomaszg7 commented 6 years ago

Didn't have time to try it yet but I have an idea to work around the problem of change in windows positions triggering a new backup version - it would be simplest just to keep windows positions in separate config file. It would have an additional benefit of making the main config file more readable and less cluttered. At the same time another two bulky sections of config file might be moved out as well: keywords and file extensions list.

In this way each file would get its own backup and it will increase the chance that important data survives.

caclark commented 6 years ago

This .diff ignores a defined set of parameters (window data) - which isn't a wonderful way of solving the problem.

An advantage of a single config file is that everything is in one place. But at the moment I don't want to make changes to the way the config data is stored.

I'll use this patch for a while to find out if I think it is useful or not before going further with it. config_history_2.diff.gz