I have a game which stores configuration and saves under $SNAP_USER_DATA. I have realised this will be a problem if someone is playing the game when the snap automatically updates. I may be wrong in my assumptions, but this is the problem I fear:
Player is playing on version x
snap updates to version y and copies all the saves and configs from version x to version y
Player continues to play on version x, not noticing the update, for a couple of hours
Player saves game and quits. Game is saved under the version x $SNAP_USER_DATA
Player restarts the game. Data are read from version y’s $SNAP_USER_DATA, which does not have the savefile from the last 2 hours of play
Player writes me an angry email
To avoid this problem, I’d rather save data under $SNAP_USER_COMMON. However, the game is already out there will a large number of installs. I need to find a way to migrate those data without replicating the savefile problem above. Ideally I need a way to trigger a copy of those data at the first ever run of version y from version x’s $SNAP_USER_DATA to $SNAP_USER_COMMON.
Is there a safe and reliable way to reference version x’s $SNAP_USER_DATA from version y? Is there a better way to do this? Am I barking up the wrong tree entirely?
I understand the concern, and the desire to keep saves separate but there is another problem which will lurk for the unwary even with moving the data into $SNAP_USER_COMMON, when updating or reverting the snap. While it will solve your immediate concern, there is potential for issues arising if you ever change the saved data file format/layout.
Consider that the user updates their saves to a new data format and then finds issues with the game which require a rollback to a version where the data format was the old style. With the data saved into $SNAP_USER_DATA this is covered by reverting the data in addition to the snap, which means losing the latest saves. However, with the data in $SNAP_USER_COMMON the user keeps their latest saves but the data file is possibly incompatible with the older version so they can’t use it anyway.
I don’t know what the solution is, as both methods have potential problems. I hope, however, to have helped to illuminate the concerns on both sides of the fence so you can make a decision that is well-informed. You are able to do either and I don’t believe one is superiour than the other, so it’s a case of finding the best way for your users, the application, and yourself as maintainer.
Sorry i can’t give you a definitive “do it this way” or “do it that way”.
I’m less worried about that as most people won’t be reverting snaps, and it would be exceptionally unlucky to revert at the point of a save file format change.