Ok, I've figured out what the issue was.
In short - XnViewMP's database dbFolder can be set to a non-existing folder through `xnview.ini` file. It doesn't seem to create the folder if it doesn't exist, yet the program will work as if everything was fine.
You can create ratings and categories, yet these don't get saved anywhere and there's no warning that this is what's happening. These also don't get saved, and will disappear.
My suggestion would be to enforce creating the dbFolder specified in the `xnview.ini` file (or registry) on startup if one doesn't exist.
------------------------
Long answer:
### Reinstallation ###
I've had XnViewMP installed on my Windows 10 machine. There, the database folder was was set to `[XnViewMP ROOT]/database` path. Also, all my photos were on a secondary drive that was mounted as `C:/second/photos/...`.
About a month ago I unmounted the secondary drive, and installed Windows 11 on it. That drive still had all the photos on it, yet the paths were no longer `C:/second/photos/...` but on `C:/photos/...`.
After intalling XnViewMP on Win 11, I've copied the `xnview.ini`, `XnView.db` and `Thumb.db` files from my old drive. This is pretty standard procedure when copying over old configuration to a new system. I've found a number of resources on XnViewMP's forum regarding backups and database file that suggested this would be the right way to go.
Remember that in this `xnview.ini` file copied over from Win 10, the dbFolder was set as `[XnViewMP ROOT]/database` which was a folder that didn't exist on the new Win 11 installation. I didn't notice that, and having used XnViewMP for a few years I didn't remember whether I've set the database folder manually when I installed it originally on my Win 10 drive.
Therefore, I have a new XnViewMP installation, with database pointing to an non-existing folder. The old `XnView.db` database file was copied to the XnViewMP ROOT, but it wasn't being read. And the catalogue is expecting photos to be in `C:/second/photos/...` which doesn't exist. Pretty horrible setup.
### Getting back to work ###
Assuming that having copied these configuration files would be enough, I didn't check the existing catalogue or my old photos. If I would, I would have noticed that none of them had the old ratings. But instead I went on and started working.
I went through a couple of new folders with photos I took recently. I added rating on these, moved the files accordingly to my ratings, everything seemed to go in order. What I assume was happening, making me believe that things are in order, is that XnViewMP was storing the new ratings in its program memory, but not saving or cross-checking these with the database file. That's all reasonable.
However, then I wanted to delete some of the files I just rated for deletion (I say 'some' - it's around 2000 ratings and a couple of hours of work, but oh well), but upon reflecting I decided not to delete them yet. XnViewMP prompts me for 'Are you sure you want to delete these 600-something items?', and I press 'No'.
At this instance, all the new ratings I made were gone. I assume that this action caused XnViewMP to attempt to save or cross-check its catalogue with the database file. Since the file was pointing to a non-existing directory, it failed, and resulted to erasing all the ratings made during that session that were until then stored in the memory.
So I notice that something is strange, and go to check my old ratings, but can also not find these. This time the reason for that is due to the fact that they were pointing at `C:/second/photos/...` instead of `C:/photos/...`. However, until now I didn't know that, so I assumed that somehow all my database got corrupted when I declined deleting the photos. I didn't notice that these are two separate problems.
### Fixing the issues ###
I've reinstalled XnViewMP, imported the database from my Win 10 setup, and then relocated the folders from `C:/second/photos/...` to `C:/photos/` by going Tools -> Settings -> Catalog -> Relocate button.
The work I've done while the program was pointing at the non-existing database folder was lost. This also explains why we couldn't see `C:\photos\sorted\BO_sucre_23_05\IMG_0037.JPG` file in the catalogue - it is one of the files rated during that cursed memory-only session.
I think this points out a couple of places that could be improved:
- Double check if dbFolder exists, and display a warning and/or create the folder on startup.
- Warn when previously recognised catalogue folders are no longer present