From 04cb132219115ca5675bde1a8bed10aab75c7bd3 Mon Sep 17 00:00:00 2001 From: aclist <92275929+aclist@users.noreply.github.com> Date: Wed, 24 Jan 2024 17:50:47 +0900 Subject: [PATCH] fix: automod WIP --- dzgui.sh | 6 +++--- helpers/funcs | 36 +++++++++++++++++------------------- helpers/ui.py | 9 +++++---- 3 files changed, 25 insertions(+), 26 deletions(-) diff --git a/dzgui.sh b/dzgui.sh index fafdccf..d3748d9 100755 --- a/dzgui.sh +++ b/dzgui.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -o pipefail -version=5.0.0.rc-28 +version=5.0.0.rc-29 #CONSTANTS aid=221100 @@ -536,10 +536,10 @@ fetch_dzq(){ fetch_helpers_by_sum(){ declare -A sums sums=( - ["ui.py"]="9b6c643d096c5b2e677b4eb17ec09750" + ["ui.py"]="12fac5997612367c0716f8575046ac6d" ["query_v2.py"]="1822bd1769ce7d7cb0d686a60f9fa197" ["vdf2json.py"]="2f49f6f5d3af919bebaab2e9c220f397" - ["funcs"]="bd5dbe82a840a25704b899e62aab0c5b" + ["funcs"]="d2afc23090f4f1e670ac8eb1a5412579" ) local author="aclist" local repo="dztui" diff --git a/helpers/funcs b/helpers/funcs index 5f8f97c..71622ba 100755 --- a/helpers/funcs +++ b/helpers/funcs @@ -1,6 +1,6 @@ #!/usr/bin/env bash set -o pipefail -version=5.0.0.rc-28 +version=5.0.0.rc-29 #CONSTANTS aid=221100 @@ -161,15 +161,6 @@ validate_and_connect(){ esac try_connect "$record" } -force_update(){ - if [[ ! $auto_install -eq 1 ]]; then - printf "Only available when mod auto-install is ON" - return 1 - fi - #TODO: force update - printf "Currently does nothing" - return 0 -} map_id_to_ip(){ local id="$1" local res=$(curl -s "$bm_api" -H "Authorization: Bearer "$api_key"" \ @@ -1084,12 +1075,13 @@ auto_mod_install(){ $steam_cmd steam://open/downloads local total=$(<<< "$diff" wc -l) - until [[ -z $(compare $diff) ]]; do - local missing=$(compare $diff | wc -l) + until [[ -z $(compare "$diff") ]]; do + local missing=$(compare "$diff" | wc -l) echo "# Downloaded $(($total-missing)) of $total mods. ESC cancels" done | $steamsafe_zenity --pulsate --progress --title="DZG Watcher" --auto-close --no-cancel --width=500 2>/dev/null if [[ ! $? -eq 0 ]]; then - exit 7 + echo "User canceled connect process. Steam may have mods pending for download." + exit 1 fi local diff=$(compare "$sanitized_mods") @@ -1103,10 +1095,15 @@ auto_mod_install(){ fi } force_update(){ + if [[ ! $auto_install -eq 1 ]]; then + printf "Only available when mod auto-install is ON" + return 1 + fi rm "$versions_file" local update=$(check_timestamps) console_dl "$update" && $steam_cmd steam://open/downloads + return 8 } console_dl(){ readarray -t modids <<< "$@" @@ -1157,21 +1154,21 @@ check_timestamps(){ local aligned=$(<<< "$local_stamps" jq -r '.response.publishedfiledetails[]|"\(.publishedfileid),\(.time_updated)"') readarray -t remote_ids < <(<<< "$aligned" awk -F, '{print $1}') readarray -t remote_times < <(<<< "$aligned" awk -F, '{print $2}') - readarray -t old_ids < <(< $versions_file awk -F, '{print 1}') - readarray -t old_times < <(< $versions_file awk -F, '{print 2}') + readarray -t old_ids < <(< $versions_file awk -F, '{print $1}') + readarray -t old_times < <(< $versions_file awk -F, '{print $2}') if [[ ! -f $versions_file ]]; then logger INFO "No prior versions file found, creating" update_stamps "$aligned" #force refresh all mods if versions file was missing - printf "%s\n" "${old_ids[$@]}" + printf "%s\n" "${remote_ids[$@]}" return 0 fi declare -A remote_version declare -A local_version - for((i = 0; i < ${remote_ids[@]}; ++i)); do + for((i = 0; i < ${#remote_ids[@]}; ++i)); do remote_version[${remote_ids[$i]}]=${remote_times[$i]} done @@ -1184,7 +1181,7 @@ check_timestamps(){ needs_update+=($id) fi done - echo "${needs_update[@]}" + printf "%s\n" "${needs_update[@]}" } merge_modlists(){ local diff="$1" @@ -1196,7 +1193,8 @@ merge_modlists(){ if [[ -z "$diff" ]] && [[ ${#needs_update[@]} -gt 0 ]]; then printf "%s\n" "${needs_update[@]}" else - printf "%s\n%s\n" "$diff" "${needs_update[@]}" + printf "%s\n" "$diff" + printf "%s\n" "${needs_update[@]}" fi } concat_mods(){ diff --git a/helpers/ui.py b/helpers/ui.py index 832b8cd..bbe166b 100644 --- a/helpers/ui.py +++ b/helpers/ui.py @@ -16,7 +16,7 @@ locale.setlocale(locale.LC_ALL, '') gi.require_version("Gtk", "3.0") from gi.repository import Gtk, GLib, Gdk, GObject, Pango -# 5.0.0-rc.28 +# 5.0.0-rc.29 app_name = "DZGUI" cache = {} @@ -309,10 +309,11 @@ def process_shell_return_code(transient_parent, msg, code, original_input): # return silently pass case 7: - # catch zenity dialog cancel and rewrite message - msg = "User canceled connect process. Steam may have mods pending for download." + msg = "Some mods may have failed to download. Try connecting again to resync." + spawn_dialog(transient_parent, msg, "NOTIFY") + case 8: + msg = "Finished requesting mod updates. Steam may have mods pending for download." spawn_dialog(transient_parent, msg, "NOTIFY") - case 90: # used to update configs and metadata in-place treeview = transient_parent.grid.scrollable_treelist.treeview