From 7268c573ea068d9f0ddac6968ae4c722f23efdf7 Mon Sep 17 00:00:00 2001 From: Astounds Date: Wed, 5 Nov 2025 21:41:46 -0500 Subject: [PATCH] test --- hyperterm/core/update.sh | 45 +++++++++++++++++++++++++++----------- hyperterm/hyperterm.sha512 | 2 +- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/hyperterm/core/update.sh b/hyperterm/core/update.sh index f49c73f..bd36e0c 100644 --- a/hyperterm/core/update.sh +++ b/hyperterm/core/update.sh @@ -99,9 +99,7 @@ function show_progress() { #------------------------------ function updbashrc() { local repo_info - local url repo_info=$(_get_repo_urls) || return 1 - url="${repo_info%|*}" # Step 1: Download checksum and _custom.sh download_file "hyperterm/hyperterm.sha512" "$HYPERTERM_DIR/hyperterm.sha512" @@ -130,22 +128,43 @@ function updbashrc() { "Get your copy at: https://c.fridu.us/software/hyperterm.git" printf '%b\n' "$RESET" else - msg "Fallo de checksum. Re-descargando archivos desde: $url" \ - "Checksum failed. Re-downloading files from: $url" + msg "Verificando archivos modificados..." \ + "Checking for modified files..." - # Count total files to download - local total_files - total_files=$(wc -l < "$HYPERTERM_DIR/hyperterm.sha512") + # Step 3: Check each file individually and download only if needed + local files_to_update=() local current_file=0 - # Step 3: Download all files from hyperterm.sha512 like list + # First pass: identify files that need updating while IFS= read -r line; do - file=$(echo "$line" | cut -d' ' -f2) - file=${file#./} - ((current_file++)) - show_progress "$current_file" "$total_files" "Descargando $file" - download_file "hyperterm/$file" "$HYPERTERM_DIR/$file" + local expected_hash file_path + expected_hash=$(echo "$line" | cut -d' ' -f1) + file_path=$(echo "$line" | cut -d' ' -f2) + file_path=${file_path#./} + local full_path="$HYPERTERM_DIR/$file_path" + + # Check if file exists and has correct hash + if [[ ! -f "$full_path" ]] || ! echo "$expected_hash ./$file_path" | (cd "$HYPERTERM_DIR" && sha512sum -c --quiet 2>/dev/null); then + files_to_update+=("$file_path") + fi done < "$HYPERTERM_DIR/hyperterm.sha512" + + local total_updates=${#files_to_update[@]} + + if [[ $total_updates -eq 0 ]]; then + msg "✔️ Todos los archivos están actualizados" \ + "✔️ All files are up to date" + else + msg "Descargando $total_updates archivo(s) modificado(s)..." \ + "Downloading $total_updates modified file(s)..." + + # Second pass: download only the files that need updating + for file_path in "${files_to_update[@]}"; do + ((current_file++)) + show_progress "$current_file" "$total_updates" "Actualizando $file_path" + download_file "hyperterm/$file_path" "$HYPERTERM_DIR/$file_path" + done + fi _colors_bash "$@" source "$HOME/.bashrc" fi diff --git a/hyperterm/hyperterm.sha512 b/hyperterm/hyperterm.sha512 index a655a02..d9cb0ac 100644 --- a/hyperterm/hyperterm.sha512 +++ b/hyperterm/hyperterm.sha512 @@ -1,6 +1,6 @@ cdfe049ec07f02a1893cda29c13085d06709e09a30b0c2e1111585278315f03139d61080c883cb3fd87f2bf64e05d9b5e5eaaad84c97ced890d83c73eb399fcb ../.bash_profile f363606f41a2c2c8f1cc44110c64fe23b1c8feb4c788ee006222db0f5c7a3adeac2b0948626b313adc985e9b8d303a0b9ce1c5ba42746810accb54efddcd4b84 ./hyperterm.sh -c625e97dd0feb1d956f7f9bbe77e238eb57effc2951b320d20c652ca2d7b0ecfd18a772af61326d93ac5627316c8a2047a1cfe47fb90647fc3613623c7051941 ./core/update.sh +6a446970145083f6b9de0dd56e37f815afb7b332b843a75ff7f874724efe074f4c9cee08c6bd1bf8f972cdb34340b2b516a4eea9a25a3e2b5e3c39175bad7387 ./core/update.sh 1cfba599047d84a17ff92b695ebf527a505a30acc9ec21a2b9f410a7ea6dde4b23b5cf62e557d82f2fe9a8980649942424b879ca53baae4d4cb3057681baa7b6 ./core/colors.sh c5ae12ee08361d1264fde5c73868fd0a80fd8810ac4e614cc333335679ad68d629d9bb88a04d27a8002d62f454105f1168df9ea63c7300c9272380b6d5311278 ./core/git.sh f3e00b2aa8ab9f3ab44570adaa2520408ed66fd00f551654d60b64a4be3546ec781b7efa39bcd774937e654b6ffb4c7af3f21eeb36caf9c01f82f85cf28e2b4d ./core/languages.sh