From d95bd3ed2e9567eace07862f17b8d668089fbdf4 Mon Sep 17 00:00:00 2001 From: Cameron Ball Date: Tue, 2 Apr 2019 14:23:28 +0800 Subject: [PATCH] Don't look for scores elsewhere in push if we don't need to --- ScoreSync.sh | 120 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 60 insertions(+), 60 deletions(-) diff --git a/ScoreSync.sh b/ScoreSync.sh index c1cf1a1..7582e3d 100755 --- a/ScoreSync.sh +++ b/ScoreSync.sh @@ -177,8 +177,6 @@ if [ "$1" = "push" ]; then # TODO: Technically these queries are not quite specific enough. They could find scores left by players other than the machine owner # but probably it's fine for fuck in "${!all_song_hashes[@]}"; do - # TODO: After the initial apply and push, running this a second time should result in way less shit in "fuck" - only stuff faved that session should be here - echo "$fuck" pathh=$(cat "${DIR}/${songs_file}" | grep $fuck | cut -sd / -f5,6 ) pathh=$(echo $pathh | sed 's/`/\\\`/g') xmlstarlet_orphans_cmd="$xmlstarlet_orphans_cmd -i \"//SongScores//Song[@Dir=\\\"Songs/${pathh}/\\\"]//Steps//HighScore[1]//PercentDP\" \ @@ -195,72 +193,74 @@ if [ "$1" = "push" ]; then --break" done - scores_living_elsewhere=$(eval "xmlstarlet sel -t $xmlstarlet_orphans_cmd -o \"SONG\" \"${path_to_stats}\"") - IFS=$'\n' read -rd '' -a scores_elsewhere <<<"$scores_living_elsewhere" - - declare -a jjj_types - declare -a jjj_diffs - declare -a jjj_scores - past_steptypes=false - past_difficulties=false - past_scores=false - no_dump=false - for i in "${scores_elsewhere[@]}"; do - if [[ ${i:0:4} = "SONG" ]]; then - if [ "$no_dump" = false ]; then - for j in "${!jjj_types[@]}"; do - writeout="${writeout}\n${jjj_hash}:${jjj_diffs[$j]}::${jjj_types[$j]}:${jjj_scores[$j]}" - done - else - writeout="${writeout}\n${jjj_hash}:NODATA" - fi + if ! [ -z "$xmlstarlet_orphans_cmd" ]; then + scores_living_elsewhere=$(eval "xmlstarlet sel -t $xmlstarlet_orphans_cmd -o \"SONG\" \"${path_to_stats}\"") + IFS=$'\n' read -rd '' -a scores_elsewhere <<<"$scores_living_elsewhere" - jjj_types=() - jjj_diffs=() - jjj_scores=() - past_steptypes=false - past_difficulties=false - past_scores=false - no_dump=false - jjj_hash=$(echo $i | cut -sd ':' -f2) - continue - fi + declare -a jjj_types + declare -a jjj_diffs + declare -a jjj_scores + past_steptypes=false + past_difficulties=false + past_scores=false + no_dump=false + for i in "${scores_elsewhere[@]}"; do + if [[ ${i:0:4} = "SONG" ]]; then + if [ "$no_dump" = false ]; then + for j in "${!jjj_types[@]}"; do + writeout="${writeout}\n${jjj_hash}:${jjj_diffs[$j]}::${jjj_types[$j]}:${jjj_scores[$j]}" + done + else + writeout="${writeout}\n${jjj_hash}:NODATA" + fi - if [ "$i" = "NOSCORES" ]; then - no_dump=true - continue - fi + jjj_types=() + jjj_diffs=() + jjj_scores=() + past_steptypes=false + past_difficulties=false + past_scores=false + no_dump=false + jjj_hash=$(echo $i | cut -sd ':' -f2) + continue + fi - if [ "$i" = "STEPTYPES" ]; then - past_steptypes=true - continue - fi + if [ "$i" = "NOSCORES" ]; then + no_dump=true + continue + fi - if [ "$i" = "DIFFICULTIES" ]; then - past_difficulties=true - continue - fi + if [ "$i" = "STEPTYPES" ]; then + past_steptypes=true + continue + fi - if [ "$i" = "SCORES" ]; then - past_scores=true - continue - fi + if [ "$i" = "DIFFICULTIES" ]; then + past_difficulties=true + continue + fi - if [ "$past_scores" = true ]; then - jjj_scores+=("$i") - continue - fi + if [ "$i" = "SCORES" ]; then + past_scores=true + continue + fi - if [ "$past_difficulties" = true ]; then - jjj_diffs+=("$i"); - continue - fi + if [ "$past_scores" = true ]; then + jjj_scores+=("$i") + continue + fi - if [ "$past_steptypes" = true ]; then - jjj_types+=("$i") - continue - fi - done + if [ "$past_difficulties" = true ]; then + jjj_diffs+=("$i"); + continue + fi + + if [ "$past_steptypes" = true ]; then + jjj_types+=("$i") + continue + fi + done + fi echo -e "$writeout" > "${DIR}/$me.scores.txt" scp "$DIR/$me.scores.txt" groovenet@cameron1729.xyz:/mnt/media/GrooveNet fi -- 2.11.0