Misc bug fixes
authorCameron Ball <cameron@cameron1729.xyz>
Mon, 1 Apr 2019 16:26:20 +0000 (00:26 +0800)
committerCameron Ball <cameron@cameron1729.xyz>
Mon, 1 Apr 2019 16:26:20 +0000 (00:26 +0800)
.gitignore
FaveSync.sh
PathsToMd5.sh
ScoreSync.sh
SongSync.sh
pull.sh

index 260c213..f7236b0 100644 (file)
@@ -1,2 +1,3 @@
 config.sh
 *.txt
+*.zip
index e68674d..048e674 100755 (executable)
@@ -7,7 +7,7 @@ if [ -z $1 ]; then
     exit
 fi
 
-songs_file=$(ls $DIR | grep songs | tail -n1)
+songs_file=$(ls "$DIR" | grep songs | tail -n1)
 
 if [ -z "$songs_file" ]; then
     exit
index 074f82d..5010c87 100755 (executable)
@@ -2,7 +2,7 @@
 
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
 
-songs_file=$(ls $DIR | grep songs | tail -n1)
+songs_file=$(ls "$DIR" | grep songs | tail -n1)
 
 if [ -z "$songs_file" ]; then
     exit
index 9fe183d..20d70ab 100755 (executable)
@@ -7,14 +7,14 @@ if [ -z $1 ]; then
     exit
 fi
 
-songs_file=$(ls $DIR | grep songs | tail -n1)
+songs_file=$(ls "$DIR" | grep songs | tail -n1)
 
 if [ -z "$songs_file" ]; then
     exit
 fi
 
 sed -i '1s/.*/<?xml version="1.0" encoding="ISO-8859-1" ?>/' "${path_to_stats}"
-difficulties=(Challenge Edit Hard Medium)
+difficulties=(Challenge Edit Hard Medium Easy)
 step_types=("dance-double" "dance-single")
 tiers=("1.00" "0.99" "0.98" "0.96" "0.94" "0.92" "0.89" "0.86" "0.83" "0.80" "0.76" "0.72" "0.68" "0.64" "0.60" "0.55")
 
@@ -74,10 +74,14 @@ if [ "$1" = "push" ]; then
 
         declare -a null_hashes
 
-        while read -r null; do
-            the_path=$(echo "$null" | cut -sd / -f2,3 | sed 's/&amp;/\&/g; s/&lt;/\</g; s/&gt;/\>/g; s/&quot;/\"/g; s/&apos;/\'"'"'/g')
-            null_hashes+=("${hash_map[$the_path]}")
-        done <<< "$nulls"
+        if ! [ -z "$nulls" ]; then
+            while read -r null; do
+                the_path=$(echo "$null" | cut -sd / -f2,3 | sed 's/&amp;/\&/g; s/&lt;/\</g; s/&gt;/\>/g; s/&quot;/\"/g; s/&apos;/\'"'"'/g')
+                if ! [ -z "${hash_map[$the_path]}" ]; then
+                    null_hashes+=("${hash_map[$the_path]}")
+                fi
+            done <<< "$nulls"
+        fi
 
         new_song=false
         song_hash=""
@@ -135,9 +139,9 @@ if [ "$1" = "push" ]; then
             fi
 
             if (( $counter % 2 )); then
-                d+=($m)
-            else
                 t+=($m)
+            else
+                d+=($m)
             fi
             counter=$((counter+1))
         done <<< "$meta"
@@ -149,7 +153,7 @@ if [ "$1" = "push" ]; then
         # if someone else has the score on it add it to writeout with NODATA
         # if it is in null nodes (need to write code for this) add it to writeout with NODATA
         # all_song_hashes should now have the information we need to retrieve the song from elsewhere in stats.xml
-        writeout=""
+        writeout="${me_highscore_name}"
         for fuck in "${!mmeta[@]}"; do
             the_score=$(echo ${mmeta[$fuck]} | cut -sd : -f1)
             the_scorer=$(echo ${mmeta[$fuck]} | cut -sd : -f2)
@@ -174,6 +178,7 @@ if [ "$1" = "push" ]; then
         # but probably it's fine
         for fuck in "${!all_song_hashes[@]}"; do
             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\" \
                                  -o \"SONG:${fuck}\" -n \
                                  -o \"STEPTYPES\" -n \
@@ -202,7 +207,7 @@ if [ "$1" = "push" ]; then
             if [[ ${i:0:4} = "SONG" ]]; then
                 if [ "$no_dump" = false ]; then
                     for j in "${!jjj_types[@]}"; do
-                        writeout="${writeout}\n${jjj_hash}:${jjj_types[$j]}::${jjj_diffs[$j]}:${jjj_scores[$j]}"
+                        writeout="${writeout}\n${jjj_hash}:${jjj_diffs[$j]}::${jjj_types[$j]}:${jjj_scores[$j]}"
                     done
                 else
                     writeout="${writeout}\n${jjj_hash}:NODATA"
@@ -292,6 +297,7 @@ if [ "$1" = "apply" ]; then
         hash_map["$hash"]+="$path"
     done <<< "$song_paths"
 
+    bros=("$me_highscore_name")
     if find "${DIR}"/*.scores.txt -type f -print -quit 2>/dev/null | grep -q .; then
         while read -d $'\0' file; do
             basename=$(basename "$file")
@@ -318,7 +324,11 @@ if [ "$1" = "apply" ]; then
                     # in the push command, null nodes get written to scores.txt as hash:NODATA
                     # so the next time apply runs, we know that they had already been copied over, and we don't have to run
                     # xmlstarlet again
-                    null_files["("$(echo $i | cut -sd : -f1)")"]+="$person"
+
+                    # TODO: This should only run when looking at the scores file for $me
+                    # Then later on when we process the pranks, unset any hashes that turn out to have a score elsewhere
+                    # before finally adding the null nodes
+                    null_files[$(echo $i | cut -sd : -f1)]+="$person"
                 else
                     song_score=$(echo $i | rev | cut -sd : -f1 | rev)
                     song_steps_type=$(echo $i | rev | cut -sd : -f2 | rev)
@@ -372,7 +382,9 @@ if [ "$1" = "apply" ]; then
 
         # only try find files for which there is actually nothing in scores.txt
         if [ "$had_score" = false ] && [ -z "${null_files[${hash}]}" ]; then
+            echo "$hash had no score and is not in nulls"
             song="${hash_map[${hash}]}"
+            song=$(echo $song | sed 's/`/\\\`/g')
             xmlstarlet_orphans_cmd="$xmlstarlet_orphans_cmd -i \"//SongScores//Song[@Dir=\\\"Songs/${song}/\\\"]//Steps//HighScore[1]//PercentDP\" \
                                  -o \"SONG:${hash}\" -n \
                                  -o \"STEPTYPES\" -n \
index fac3202..228da8c 100755 (executable)
@@ -48,7 +48,6 @@ if [ "$1" = "apply" ]; then
         path=$(echo $m | cut -sd / -f5,6)
 
         if [[ ${m:0:1} = "+" ]]; then
-    echo "$m"
             if ! [ -z "${adds[${path}]}" ]; then
                 echo "More than one SM file in ${path}, aborting"
                 exit
@@ -57,7 +56,6 @@ if [ "$1" = "apply" ]; then
         fi
 
         if [[ ${m:0:1} = "-" ]]; then
-    echo "$m"
             # It can happan that a path is already in removes if there are multiple SM files in a directory
             # this should not really happen since there's the check above that refuses to add any files with that
             # problem. However when I do the initial sync on our machines they will have problematic files.
diff --git a/pull.sh b/pull.sh
index 108b751..669131a 100755 (executable)
--- a/pull.sh
+++ b/pull.sh
@@ -4,19 +4,19 @@ DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
 source "$DIR/config.sh"
 
 date=$(date +%s)
-for f in ${DIR}/*.scores.txt; do
+for f in "${DIR}"/*.scores.txt; do
     base=$(basename "$f" | cut -sd . -f1,2)
     mv -- "$f" "${DIR}/${base}.${date}.txt"
 done
 
-for f in ${DIR}/*.favourites.txt; do
+for f in "${DIR}"/*.favourites.txt; do
     base=$(basename "$f" | cut -sd . -f1,2)
     mv -- "$f" "${DIR}/${base}.${date}.txt"
 done
 
 scp groovenet@cameron1729.xyz:/mnt/media/GrooveNet/*.txt "$DIR"
 
-for f in ${DIR}/*.scores.txt; do
+for f in "${DIR}"/*.scores.txt; do
     base=$(basename "$f" | cut -sd . -f1,2)
     backed_up_file="${base}.${date}.txt"
     if [ -f "${DIR}/$backed_up_file" ]; then
@@ -29,7 +29,7 @@ for f in ${DIR}/*.scores.txt; do
     fi
 done
 
-for f in ${DIR}/*.favourites.txt; do
+for f in "${DIR}"/*.favourites.txt; do
     base=$(basename "$f" | cut -sd . -f1,2)
     backed_up_file="${base}.${date}.txt"
     if [ -f "${DIR}/$backed_up_file" ]; then