From 4742f7f7f4e728675d6e434c33f566c2a35a6026 Mon Sep 17 00:00:00 2001 From: Gardouille Date: Wed, 9 Oct 2019 00:31:18 +0200 Subject: [PATCH] Successfull move save of compatdata directory --- games/save.game.steam | 46 ++++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/games/save.game.steam b/games/save.game.steam index 1475d40..8a8a7de 100755 --- a/games/save.game.steam +++ b/games/save.game.steam @@ -43,12 +43,16 @@ steam_compatdata=".steam/steam/steamapps/compatdata" ### 359840 − Shift Happens − https://pcgamingwiki.com/wiki/Shift_Happens steam_userdata_games="760 35700 35720 55230 204360 206420 218820 247080 255870 312530 359840" ## }}} -# List of Steam saves in compatdata to backup {{{ +## Pattern of Steam saves in compatdata to backup {{{ +### Compatdata is the directory for games using Steam play so it's too big to +### be moved to a remote storage. +### Add the game id and the directory|file name to backup separated by a slash +### eg. GAME_ID/savedata.xml ### 213670 − South Park: The Stick of Truth − https://pcgamingwiki.com/wiki/South_Park:_The_Stick_of_Truth ### 359840 − Shift Happens − https://pcgamingwiki.com/wiki/Shift_Happens ### 480490 − Prey (2017) − https://pcgamingwiki.com/wiki/Prey_(2017) ### 686200 − Door Kickers: Action Squad − https://pcgamingwiki.com/wiki/Door_Kickers:_Action_Squad -steam_compatdata_games="686200" +steam_compatdata_games_pattern="686200/userdata.bin" # }}} ## List of Steam saves in steamapps to backup {{{ ### 274190 − Broforce − https://pcgamingwiki.com/wiki/Broforce @@ -171,28 +175,46 @@ for game_id in ${steam_userdata_games}; do done # }}} # Manage Steam compadata save game {{{ -for game_id in ${steam_compatdata_games}; do - local_game_path="${HOME}/${steam_compatdata}/${game_id}" - local_game_path_type="$(file "${local_game_path}" | cut -d' ' -f2)" +for game_pattern in ${steam_compatdata_games_pattern}; do + ## Separate the game_id and the directory|file to backup|symlink + game_id="$(echo ${game_pattern} | cut -d"/" -f1)" + save_pattern="$(echo ${game_pattern} | cut -d"/" -f2)" - case ${local_game_path_type} in + ### Follow symbolic links but avoid links to dosdevices and keep only one result + temp_local_save_path="$(find -L "${HOME}/${steam_compatdata}/${game_id}" -ipath "*dosdevices*" -prune -o -iname "${save_pattern}" | grep -v "dosdevices" | head -n 1)" + local_save_path="$(dirname "${temp_local_save_path}")" + local_save_path_type="$(ls -ld "${local_save_path}" | sed 's/\(^.\).*/\1/')" + ## Path independent from local or remote base directory + steam_dir="$(printf "%s" "${local_save_path}" | sed -e "s;${HOME}/;;")" + + ## Print vars {{{ + #if [ "${debug}" -eq "0" ]; then + #printf '\e[1;35m%-6s\e[m\n' "DEBUG : game ID : ${game_id}" + #printf '\e[1;35m%-6s\e[m\n' "DEBUG : save pattern : ${save_pattern}" + #printf '\e[1;35m%-6s\e[m\n' "DEBUG : temp local save path : ${temp_local_save_path}" + #printf '\e[1;35m%-6s\e[m\n' "DEBUG : local save path : ${local_save_path}" + #printf '\e[1;35m%-6s\e[m\n' "DEBUG : local save type : ${local_save_path_type}" + #printf '\e[1;35m%-6s\e[m\n' "DEBUG : steam dir : ${steam_dir}" + #fi + ## }}} + + case ${local_save_path_type} in ## Data is already a symlink - "symbolic") + "symbolic"|"symboliclink"|"l") [ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Steam compatdata for loop — The data of ${game_id} are already symlinked to .... Skip." ;; ## Data is still a directory, try to move it - "directory") - ### TODO : - printf '\e[1;35m%-6s\e[m\n' "Steam compatdata for loop − The data of ${game_id} − ${local_game_path} need to move." + "directory"|"d") + move_steam_game_dir "$(basename "${steam_dir}")" "$(dirname "${steam_dir}")" ;; ## Data doesn't exist "cannot") - [ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Steam compatdata for loop — The data of ${game_id} − ${local_game_path} doesn't exist. Skip." + [ "${debug}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Steam compatdata for loop — The data of ${game_id} − ${local_save_path} doesn't exist. Skip." ### TODO : Try to symlink ;; ## Data can't be managed *) - printf '\e[1;35m%-6s\e[m\n' "Data of ${game_id} (compatdata) − ${local_game_path} are not managed. Type: ${local_game_path_type}. Abort : $(file "${local_game_path}")" + printf '\e[1;35m%-6s\e[m\n' "Data of ${game_id} (compatdata) − ${local_save_path} are not managed. Type: ${local_save_path_type}. Abort." exit 3 ;; esac