Managing Location Of User Files In SNAP App Revision Updates

You may notice in your SNAP folder that after an upgrade the older version ‘config’ files remain, while new version has been created and a symlink called current that pointed to the previous revision now points to the new revision. An example of this might look like ~/snap/blender/35/36/current/ - the previous version was 35 and the updated/current now points to 36.

When you open the application it’s default user save location might actually be the 35 or 36 folder and an inexperienced user may save their file there, and later fiddle around with preferences and change the save location to, for example, ~/Videos or similar, and not remember where the earlier files they saved in ~/snap/blender/35/ or ~/snap/blender/36 are. This could result in a support call and your life as a system administrator is actually about finding ways to do as little as possible and keeping pizza and pepsi allnighter costs down.

A way to address this if your distro has the /etc/profile.d/ ( I know I am eventually going to attract someone who will castigate me for espousing this) - but be careful and you can use this file to run things at login time, is to create 'inter-version symlinks" to known save locations during login by identifying current and previous SNAP revisions of applications. Here is an example of a ‘script’ in /etc/profile.d/ to address this:

A solution is to put this in your /etc/profile.d/ file:

rev=$(ls -dt -- /snap/kdenlive/*/ | head -n1); echo "${VAR::-1}"
rev=$(sed 's|snap/kdenlive/||g' <<< $rev)
mkdir -p ~/snap/kdenlive"$rev"Videos
mkdir -p ~/Videos/kdenlive"$rev"
ln -s ~/snap/kdenlive"$rev"Videos ~/Videos/kdenlive"$rev"

When your user first saves using the first installed SNAP revision of the app (this example kdenlive), their ~/snap/application_name/revision/ working folder is symlinked to the ~/Videos folder and when the SNAP application is updated to a later revision, next time they login that version is also symlinked to the ~/Videos folder.

How the above works:

rev=$(ls -dt – /snap/kdenlive/*/ | head -n1); echo “${VAR::-1}”
**** Declare variable rev by querying the most recent timestamped child folder created in the parent path of the system installation path of the SNAP application.

rev=$(sed ‘s|snap/kdenlive/||g’ <<< $rev)
**** Update the variable by replacing the parent path with nothing… and what remains is that you have the latest folder revision number.

mkdir -p ~/snap/kdenlive"$rev"Videos
**** Make a folder path for that revision and an intuitive save folder name in the user ~/snap/application_name/revision directory (in SNAP user folder space, not system installation).

mkdir -p ~/Videos/kdenlive"$rev"
**** Make a folder for the SNAP revision in the desired target user save folder

ln -s ~/snap/kdenlive"$rev"Videos ~/Videos/kdenlive"$rev"
**** Symlink the ~/snap/applicationname/revision folder to the target save folder by revision.

If anyone who understands this can think of simpler way to explain it all please feel free !